From 9be8ab06ed88ff69ff37334c929552d3fb5c2ac8 Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Fri, 18 Jan 2019 17:55:00 +0300 Subject: [PATCH 01/10] Update photo.hpp --- modules/photo/include/opencv2/photo.hpp | 113 ++++++++++++++---------- 1 file changed, 67 insertions(+), 46 deletions(-) diff --git a/modules/photo/include/opencv2/photo.hpp b/modules/photo/include/opencv2/photo.hpp index 7ceb97e27b..13c0ea5820 100644 --- a/modules/photo/include/opencv2/photo.hpp +++ b/modules/photo/include/opencv2/photo.hpp @@ -48,16 +48,35 @@ /** @defgroup photo Computational Photography + +This module includes photo processing algorithms @{ + @defgroup photo_inpaint Inpainting @defgroup photo_denoise Denoising @defgroup photo_hdr HDR imaging This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment, camera calibration with multiple exposures and exposure fusion. + @defgroup photo_decolor Contrast Preserving Decolorization + +Useful links: + +http://www.cse.cuhk.edu.hk/leojia/projects/color2gray/index.html + @defgroup photo_clone Seamless Cloning + +Useful links: + +https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp + @defgroup photo_render Non-Photorealistic Rendering - @defgroup photo_c C API + +Useful links: + +http://www.inf.ufrgs.br/~eslgastal/DomainTransform + +https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/ @} */ @@ -67,24 +86,13 @@ namespace cv //! @addtogroup photo //! @{ +//! @addtogroup photo_inpaint +//! @{ //! the inpainting algorithm enum { - INPAINT_NS = 0, // Navier-Stokes algorithm - INPAINT_TELEA = 1 // A. Telea algorithm -}; - -enum -{ - NORMAL_CLONE = 1, - MIXED_CLONE = 2, - MONOCHROME_TRANSFER = 3 -}; - -enum -{ - RECURS_FILTER = 1, - NORMCONV_FILTER = 2 + INPAINT_NS = 0, //!< Use Navier-Stokes based method + INPAINT_TELEA = 1 //!< Use the algorithm proposed by Alexandru Telea @cite Telea04 }; /** @brief Restores the selected region in an image using the region neighborhood. @@ -95,9 +103,7 @@ needs to be inpainted. @param dst Output image with the same size and type as src . @param inpaintRadius Radius of a circular neighborhood of each point inpainted that is considered by the algorithm. -@param flags Inpainting method that could be one of the following: -- **INPAINT_NS** Navier-Stokes based method [Navier01] -- **INPAINT_TELEA** Method by Alexandru Telea @cite Telea04 . +@param flags Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA The function reconstructs the selected image area from the pixel near the area boundary. The function may be used to remove dust and scratches from a scanned photo, or to remove undesirable @@ -106,12 +112,14 @@ objects from still images or video. See createMergeRobertson(); //! @} photo_hdr +//! @addtogroup photo_decolor +//! @{ + /** @brief Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized black-and-white photograph rendering, and in many single channel image processing applications @cite CL12 . @@ -690,9 +701,24 @@ This function is to be applied on color images. */ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost); +//! @} photo_decolor + //! @addtogroup photo_clone //! @{ + +//! seamlessClone algorithm flags +enum +{ + /** The power of the method is fully expressed when inserting objects with complex outlines into a new background*/ + NORMAL_CLONE = 1, + /** The classic method, color-based selection and alpha masking might be time 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.*/ + MIXED_CLONE = 2, + /** Monochrome transfer allows the user to easily replace certain features of one object by alternative features.*/ + MONOCHROME_TRANSFER = 3}; + + /** @example samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp An example using seamlessClone function */ @@ -707,15 +733,7 @@ content @cite PM03 . @param mask Input 8-bit 1 or 3-channel image. @param p Point in dst image where object is placed. @param blend Output image with the same size and type as dst. -@param flags Cloning method that could be one of the following: -- **NORMAL_CLONE** The power of the method is fully expressed when inserting objects with -complex outlines into a new background -- **MIXED_CLONE** The classic method, color-based selection and alpha masking might be time -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. -- **MONOCHROME_TRANSFER** Monochrome transfer allows the user to easily replace certain features of -one object by alternative features. +@param flags Cloning method that could be cv::NORMAL_CLONE, cv::MIXED_CLONE or cv::MONOCHROME_TRANSFER */ CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p, OutputArray blend, int flags); @@ -750,18 +768,16 @@ CV_EXPORTS_W void illuminationChange(InputArray src, InputArray mask, OutputArra float alpha = 0.2f, float beta = 0.4f); /** @brief By retaining only the gradients at edge locations, before integrating with the Poisson solver, one -washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge -Detector is used. +washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used. @param src Input 8-bit 3-channel image. @param mask Input 8-bit 1 or 3-channel image. @param dst Output image with the same size and type as src. -@param low_threshold Range from 0 to 100. +@param low_threshold %Range from 0 to 100. @param high_threshold Value \> 100. @param kernel_size The size of the Sobel kernel to be used. -**NOTE:** - +@note The algorithm assumes that the color of the source image is close to that of the destination. This assumption means that when the colors don't match, the source image color gets tinted toward the color of the destination image. @@ -775,16 +791,21 @@ CV_EXPORTS_W void textureFlattening(InputArray src, InputArray mask, OutputArray //! @addtogroup photo_render //! @{ +//! Edge preserving filters +enum +{ + RECURS_FILTER = 1, //!< Recursive Filtering + NORMCONV_FILTER = 2 //!< Normalized Convolution Filtering +}; + /** @brief Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing filters are used in many different applications @cite EM11 . @param src Input 8-bit 3-channel image. @param dst Output 8-bit 3-channel image. -@param flags Edge preserving filters: -- **RECURS_FILTER** = 1 -- **NORMCONV_FILTER** = 2 -@param sigma_s Range between 0 to 200. -@param sigma_r Range between 0 to 1. +@param flags Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. */ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flags = 1, float sigma_s = 60, float sigma_r = 0.4f); @@ -793,8 +814,8 @@ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flag @param src Input 8-bit 3-channel image. @param dst Output image with the same size and type as src. -@param sigma_s Range between 0 to 200. -@param sigma_r Range between 0 to 1. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. */ CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10, float sigma_r = 0.15f); @@ -807,9 +828,9 @@ An example using non-photorealistic line drawing functions @param src Input 8-bit 3-channel image. @param dst1 Output 8-bit 1-channel image. @param dst2 Output image with the same size and type as src. -@param sigma_s Range between 0 to 200. -@param sigma_r Range between 0 to 1. -@param shade_factor Range between 0 to 0.1. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. +@param shade_factor %Range between 0 to 0.1. */ CV_EXPORTS_W void pencilSketch(InputArray src, OutputArray dst1, OutputArray dst2, float sigma_s = 60, float sigma_r = 0.07f, float shade_factor = 0.02f); @@ -820,8 +841,8 @@ contrast while preserving, or enhancing, high-contrast features. @param src Input 8-bit 3-channel image. @param dst Output image with the same size and type as src. -@param sigma_s Range between 0 to 200. -@param sigma_r Range between 0 to 1. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. */ CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 60, float sigma_r = 0.45f); From 110e80f0ee3170524401b6cd66e1b2590afb9282 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Mon, 11 Mar 2019 11:44:16 +0300 Subject: [PATCH 02/10] Add onRuntimeInitialized for opencv.js --- doc/js_tutorials/js_assets/utils.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/js_tutorials/js_assets/utils.js b/doc/js_tutorials/js_assets/utils.js index 8e56396aba..4d5deb0b51 100644 --- a/doc/js_tutorials/js_assets/utils.js +++ b/doc/js_tutorials/js_assets/utils.js @@ -8,8 +8,19 @@ function Utils(errorOutputId) { // eslint-disable-line no-unused-vars script.setAttribute('async', ''); script.setAttribute('type', 'text/javascript'); script.addEventListener('load', () => { - console.log(cv.getBuildInformation()); - onloadCallback(); + if (cv.getBuildInformation) + { + console.log(cv.getBuildInformation()); + onloadCallback(); + } + else + { + // WASM + cv['onRuntimeInitialized']=()=>{ + console.log(cv.getBuildInformation()); + onloadCallback(); + } + } }); script.addEventListener('error', () => { self.printError('Failed to load ' + OPENCV_URL); From af0a83f0b3a4c46ef2bc87ad1648831760f51fb4 Mon Sep 17 00:00:00 2001 From: LaurentBerger Date: Mon, 11 Mar 2019 16:48:10 +0100 Subject: [PATCH 03/10] Tutorial create pattern grid for calibration using gen_pattern.py --- .../camera_calibration_pattern.markdown | 33 +++++++++++++++++++ .../calib3d/table_of_content_calib3d.markdown | 8 +++++ 2 files changed, 41 insertions(+) create mode 100644 doc/tutorials/calib3d/camera_calibration_pattern/camera_calibration_pattern.markdown diff --git a/doc/tutorials/calib3d/camera_calibration_pattern/camera_calibration_pattern.markdown b/doc/tutorials/calib3d/camera_calibration_pattern/camera_calibration_pattern.markdown new file mode 100644 index 0000000000..de219a60f4 --- /dev/null +++ b/doc/tutorials/calib3d/camera_calibration_pattern/camera_calibration_pattern.markdown @@ -0,0 +1,33 @@ +Create calibration pattern {#tutorial_camera_calibration_pattern} +========================================= + +The goal of this tutorial is to learn how to create calibration pattern. + +You can find a chessboard pattern in https://github.com/opencv/opencv/blob/3.4/doc/pattern.png + +You can find a circleboard pattern in https://github.com/opencv/opencv/blob/3.4/doc/acircles_pattern.png + +Create your own pattern +--------------- + +Now, if you want to create your own pattern, you will need python to use https://github.com/opencv/opencv/blob/3.4/doc/pattern_tools/gen_pattern.py + +Example + +create a checkerboard pattern in file chessboard.svg with 9 rows, 6 columns and a square size of 20mm: + + python gen_pattern.py -o chessboard.svg --rows 9 --columns 6 --type checkerboard --square_size 20 + +create a circle board pattern in file circleboard.svg with 7 rows, 5 columns and a radius of 15mm: + + python gen_pattern.py -o circleboard.svg --rows 7 --columns 5 --type circles --square_size 15 + +create a circle board pattern in file acircleboard.svg with 7 rows, 5 columns and a square size of 10mm and less spacing between circle: + + python gen_pattern.py -o acircleboard.svg --rows 7 --columns 5 --type acircles --square_size 10 --radius_rate 2 + +If you want to change unit use -u option (mm inches, px, m) + +If you want to change page size use -w and -h options + +If you want to create a ChArUco board read tutorial Detection of ChArUco Corners in opencv_contrib tutorial(https://docs.opencv.org/3.4/df/d4a/tutorial_charuco_detection.html) \ No newline at end of file diff --git a/doc/tutorials/calib3d/table_of_content_calib3d.markdown b/doc/tutorials/calib3d/table_of_content_calib3d.markdown index 20ca778d5f..d99a4db59e 100644 --- a/doc/tutorials/calib3d/table_of_content_calib3d.markdown +++ b/doc/tutorials/calib3d/table_of_content_calib3d.markdown @@ -3,6 +3,14 @@ Camera calibration and 3D reconstruction (calib3d module) {#tutorial_table_of_co 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_pattern + + *Compatibility:* \> OpenCV 2.0 + + *Author:* Laurent Berger + + You will learn how to create some calibration pattern. + - @subpage tutorial_camera_calibration_square_chess *Compatibility:* \> OpenCV 2.0 From 80e5642ca2366c470cba1f548b9f55c79b1f387e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 12 Mar 2019 13:29:42 +0300 Subject: [PATCH 04/10] pre: OpenCV 3.4.6 (version++) --- doc/tutorials/dnn/dnn_android/dnn_android.markdown | 2 +- .../cross_referencing/tutorial_cross_referencing.markdown | 4 ++-- modules/core/include/opencv2/core/version.hpp | 4 ++-- platforms/android/build_sdk.py | 2 +- platforms/android/service/engine/AndroidManifest.xml | 4 ++-- .../engine/src/org/opencv/engine/OpenCVEngineService.java | 2 +- platforms/android/service/readme.txt | 2 +- platforms/maven/opencv-it/pom.xml | 2 +- platforms/maven/opencv/pom.xml | 2 +- platforms/maven/pom.xml | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/tutorials/dnn/dnn_android/dnn_android.markdown b/doc/tutorials/dnn/dnn_android/dnn_android.markdown index 58bda98e89..23a14c9163 100644 --- a/doc/tutorials/dnn/dnn_android/dnn_android.markdown +++ b/doc/tutorials/dnn/dnn_android/dnn_android.markdown @@ -12,7 +12,7 @@ Tutorial was written for the following versions of corresponding software: - Download and install Android Studio from https://developer.android.com/studio. -- Get the latest pre-built OpenCV for Android release from https://github.com/opencv/opencv/releases and unpack it (for example, `opencv-3.4.5-android-sdk.zip`). +- Get the latest pre-built OpenCV for Android release from https://github.com/opencv/opencv/releases and unpack it (for example, `opencv-3.4.6-android-sdk.zip`). - Download MobileNet object detection model from https://github.com/chuanqi305/MobileNet-SSD. We need a configuration file `MobileNetSSD_deploy.prototxt` and weights `MobileNetSSD_deploy.caffemodel`. diff --git a/doc/tutorials/introduction/cross_referencing/tutorial_cross_referencing.markdown b/doc/tutorials/introduction/cross_referencing/tutorial_cross_referencing.markdown index 55fcd57f4f..add582a8d5 100644 --- a/doc/tutorials/introduction/cross_referencing/tutorial_cross_referencing.markdown +++ b/doc/tutorials/introduction/cross_referencing/tutorial_cross_referencing.markdown @@ -36,14 +36,14 @@ Open your Doxyfile using your favorite text editor and search for the key `TAGFILES`. Change it as follows: @code -TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.5 +TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.6 @endcode If you had other definitions already, you can append the line using a `\`: @code TAGFILES = ./docs/doxygen-tags/libstdc++.tag=https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen \ - ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.5 + ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.6 @endcode Doxygen can now use the information from the tag file to link to the OpenCV diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index c75800619a..4f44ebd594 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -7,8 +7,8 @@ #define CV_VERSION_MAJOR 3 #define CV_VERSION_MINOR 4 -#define CV_VERSION_REVISION 5 -#define CV_VERSION_STATUS "-dev" +#define CV_VERSION_REVISION 6 +#define CV_VERSION_STATUS "-pre" #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) diff --git a/platforms/android/build_sdk.py b/platforms/android/build_sdk.py index 29ca1926c7..9d46f0e0e0 100755 --- a/platforms/android/build_sdk.py +++ b/platforms/android/build_sdk.py @@ -257,7 +257,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.4.5", os.path.join(self.libdest, "lib"))]: + for ver, d in self.extra_packs + [("3.4.6", 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 660152ed29..716b7ed584 100644 --- a/platforms/android/service/engine/AndroidManifest.xml +++ b/platforms/android/service/engine/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="346@ANDROID_PLATFORM_ID@" + android:versionName="3.46"> 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 850bad5349..bf4e5f15f4 100644 --- a/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java +++ b/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java @@ -137,7 +137,7 @@ public class OpenCVEngineService extends Service { @Override public int getEngineVersion() throws RemoteException { - int version = 3450; + int version = 3460; 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 b77adbca79..c7e7b82d48 100644 --- a/platforms/android/service/readme.txt +++ b/platforms/android/service/readme.txt @@ -12,7 +12,7 @@ manually using adb tool: adb install /apk/OpenCV__Manager__.apk -Example: OpenCV_3.4.5-dev_Manager_3.45_armeabi-v7a.apk +Example: OpenCV_3.4.6-dev_Manager_3.45_armeabi-v7a.apk Use the list of platforms below to determine proper OpenCV Manager package for your device: diff --git a/platforms/maven/opencv-it/pom.xml b/platforms/maven/opencv-it/pom.xml index 37cfdce2fa..f772020c36 100644 --- a/platforms/maven/opencv-it/pom.xml +++ b/platforms/maven/opencv-it/pom.xml @@ -4,7 +4,7 @@ org.opencv opencv-parent - 3.4.5 + 3.4.6 org.opencv opencv-it diff --git a/platforms/maven/opencv/pom.xml b/platforms/maven/opencv/pom.xml index da2889c70f..c914ea4036 100644 --- a/platforms/maven/opencv/pom.xml +++ b/platforms/maven/opencv/pom.xml @@ -4,7 +4,7 @@ org.opencv opencv-parent - 3.4.5 + 3.4.6 org.opencv opencv diff --git a/platforms/maven/pom.xml b/platforms/maven/pom.xml index 6fb2fb4f9e..d8ea930529 100644 --- a/platforms/maven/pom.xml +++ b/platforms/maven/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.opencv opencv-parent - 3.4.5 + 3.4.6 pom OpenCV Parent POM From 2143f7cee111514dab24fab3dd79a9f320678054 Mon Sep 17 00:00:00 2001 From: Josh Veitch-Michaelis Date: Tue, 12 Mar 2019 05:26:51 +0000 Subject: [PATCH 05/10] release frame after disabling convert rgb --- modules/videoio/src/cap_v4l.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp index 822f37344f..c79d9044a9 100644 --- a/modules/videoio/src/cap_v4l.cpp +++ b/modules/videoio/src/cap_v4l.cpp @@ -1803,9 +1803,11 @@ bool CvCaptureCAM_V4L::setProperty( int property_id, double _value ) if (bool(value)) { convert_rgb = convertableToRgb(); return convert_rgb; + }else{ + convert_rgb = false; + releaseFrame(); + return true; } - convert_rgb = false; - return true; case cv::CAP_PROP_FOURCC: { if (palette == static_cast<__u32>(value)) From 18ab85efc24cbce712ac01fd6b0ac98e52634379 Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 13 Mar 2019 13:30:04 +0300 Subject: [PATCH 06/10] Backport commits from https://github.com/opencv/opencv/pull/12601 https://github.com/opencv/opencv/pull/12622 --- modules/js/src/embindgen.py | 38 ++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/js/src/embindgen.py b/modules/js/src/embindgen.py index d85a525a8d..ec62bc86d0 100644 --- a/modules/js/src/embindgen.py +++ b/modules/js/src/embindgen.py @@ -70,7 +70,6 @@ from __future__ import print_function import sys, re, os from templates import * -from sets import Set if sys.version_info[0] >= 3: from io import StringIO @@ -120,7 +119,7 @@ objdetect = {'': ['groupRectangles'], 'HOGDescriptor': ['load', 'HOGDescriptor', 'getDefaultPeopleDetector', 'getDaimlerPeopleDetector', 'setSVMDetector', 'detectMultiScale'], 'CascadeClassifier': ['load', 'detectMultiScale2', 'CascadeClassifier', 'detectMultiScale3', 'empty', 'detectMultiScale']} -video = {'': ['CamShift', 'calcOpticalFlowFarneback', 'calcOpticalFlowPyrLK', 'createBackgroundSubtractorMOG2', 'estimateRigidTransform',\ +video = {'': ['CamShift', 'calcOpticalFlowFarneback', 'calcOpticalFlowPyrLK', 'createBackgroundSubtractorMOG2', \ 'findTransformECC', 'meanShift'], 'BackgroundSubtractorMOG2': ['BackgroundSubtractorMOG2', 'apply'], 'BackgroundSubtractor': ['apply', 'getBackgroundImage']} @@ -200,7 +199,7 @@ class ClassInfo(object): self.consts = {} customname = False self.jsfuncs = {} - self.constructor_arg_num = Set() + self.constructor_arg_num = set() self.has_smart_ptr = False @@ -385,14 +384,23 @@ class JSWrapperGenerator(object): return namespace, classes, chunks[-1] def add_enum(self, decl): - name = decl[1] + name = decl[0].rsplit(" ", 1)[1] namespace, classes, val = self.split_decl_name(name) namespace = '.'.join(namespace) - val = '_'.join(classes + [name]) - cname = name.replace('.', '::') ns = self.namespaces.setdefault(namespace, Namespace()) + if len(name) == 0: name = "" + if name.endswith(""): + i = 0 + while True: + i += 1 + candidate_name = name.replace("", "unnamed_%u" % i) + if candidate_name not in ns.enums: + name = candidate_name + break; + cname = name.replace('.', '::') + type_dict[normalize_class_name(name)] = cname if name in ns.enums: - print("Generator warning: constant %s (cname=%s) already exists" \ + print("Generator warning: enum %s (cname=%s) already exists" \ % (name, cname)) # sys.exit(-1) else: @@ -400,6 +408,12 @@ class JSWrapperGenerator(object): for item in decl[3]: ns.enums[name].append(item) + const_decls = decl[3] + + for decl in const_decls: + name = decl[0] + self.add_const(name.replace("const ", "").strip(), decl) + def add_const(self, name, decl): cname = name.replace('.','::') namespace, classes, name = self.split_decl_name(name) @@ -819,7 +833,7 @@ class JSWrapperGenerator(object): continue # Generate bindings for methods - for method_name, method in class_info.methods.iteritems(): + for method_name, method in class_info.methods.items(): if method.cname in ignore_list: continue if not method.name in white_list[method.class_name]: @@ -828,7 +842,8 @@ class JSWrapperGenerator(object): for variant in method.variants: args = [] for arg in variant.args: - args.append(arg.tp) + arg_type = type_dict[arg.tp] if arg.tp in type_dict else arg.tp + args.append(arg_type) # print('Constructor: ', class_info.name, len(variant.args)) args_num = len(variant.args) if args_num in class_info.constructor_arg_num: @@ -849,7 +864,7 @@ class JSWrapperGenerator(object): class_bindings.append(smart_ptr_reg_template.substitute(cname=class_info.cname, name=class_info.name)) # Attach external constructors - # for method_name, method in class_info.ext_constructors.iteritems(): + # for method_name, method in class_info.ext_constructors.items(): # print("ext constructor", method_name) #if class_info.ext_constructors: @@ -857,7 +872,8 @@ class JSWrapperGenerator(object): # Generate bindings for properties for property in class_info.props: - class_bindings.append(class_property_template.substitute(js_name=property.name, cpp_name='::'.join( + _class_property = class_property_enum_template if property.tp in type_dict else class_property_template + class_bindings.append(_class_property.substitute(js_name=property.name, cpp_name='::'.join( [class_info.cname, property.name]))) dv = '' From a54affeb8d9bb52b43228fa89ca31c68ff088202 Mon Sep 17 00:00:00 2001 From: Namgoo Lee Date: Wed, 13 Mar 2019 18:52:11 +0900 Subject: [PATCH 07/10] Move Ptr-related code from lut.cu to lut.cpp --- modules/cudaarithm/src/core.cpp | 2 -- modules/cudaarithm/src/cuda/lut.cu | 26 +++++--------------------- modules/cudaarithm/src/lut.cpp | 23 +++++++++++++++++++++++ modules/cudaarithm/src/lut.hpp | 30 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 modules/cudaarithm/src/lut.cpp create mode 100644 modules/cudaarithm/src/lut.hpp diff --git a/modules/cudaarithm/src/core.cpp b/modules/cudaarithm/src/core.cpp index 7dd51f9781..6d97e15dbb 100644 --- a/modules/cudaarithm/src/core.cpp +++ b/modules/cudaarithm/src/core.cpp @@ -57,8 +57,6 @@ void cv::cuda::transpose(InputArray, OutputArray, Stream&) { throw_no_cuda(); } void cv::cuda::flip(InputArray, OutputArray, int, Stream&) { throw_no_cuda(); } -Ptr cv::cuda::createLookUpTable(InputArray) { throw_no_cuda(); return Ptr(); } - void cv::cuda::copyMakeBorder(InputArray, OutputArray, int, int, int, int, int, Scalar, Stream&) { throw_no_cuda(); } #else /* !defined (HAVE_CUDA) */ diff --git a/modules/cudaarithm/src/cuda/lut.cu b/modules/cudaarithm/src/cuda/lut.cu index 1769116d30..336f9b2885 100644 --- a/modules/cudaarithm/src/cuda/lut.cu +++ b/modules/cudaarithm/src/cuda/lut.cu @@ -48,6 +48,8 @@ #else +#include "../lut.hpp" + #include "opencv2/cudaarithm.hpp" #include "opencv2/cudev.hpp" #include "opencv2/core/private.cuda.hpp" @@ -56,24 +58,10 @@ using namespace cv; using namespace cv::cuda; using namespace cv::cudev; -namespace -{ +namespace cv { namespace cuda { + texture texLutTable; - class LookUpTableImpl : public LookUpTable - { - public: - LookUpTableImpl(InputArray lut); - ~LookUpTableImpl(); - - void transform(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) CV_OVERRIDE; - - private: - GpuMat d_lut; - cudaTextureObject_t texLutTableObj; - bool cc30; - }; - LookUpTableImpl::LookUpTableImpl(InputArray _lut) { if (_lut.kind() == _InputArray::CUDA_GPU_MAT) @@ -200,11 +188,7 @@ namespace syncOutput(dst, _dst, stream); } -} -Ptr cv::cuda::createLookUpTable(InputArray lut) -{ - return makePtr(lut); -} +} } #endif diff --git a/modules/cudaarithm/src/lut.cpp b/modules/cudaarithm/src/lut.cpp new file mode 100644 index 0000000000..a4b4e02650 --- /dev/null +++ b/modules/cudaarithm/src/lut.cpp @@ -0,0 +1,23 @@ +// 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 "lut.hpp" + +using namespace cv; +using namespace cv::cuda; + +#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) + +Ptr cv::cuda::createLookUpTable(InputArray) { throw_no_cuda(); return Ptr(); } + +#else /* !defined (HAVE_CUDA) || defined (CUDA_DISABLER) */ + +Ptr cv::cuda::createLookUpTable(InputArray lut) +{ + return makePtr(lut); +} + +#endif diff --git a/modules/cudaarithm/src/lut.hpp b/modules/cudaarithm/src/lut.hpp new file mode 100644 index 0000000000..2c63e9acdf --- /dev/null +++ b/modules/cudaarithm/src/lut.hpp @@ -0,0 +1,30 @@ +// 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 __CUDAARITHM_LUT_HPP__ +#define __CUDAARITHM_LUT_HPP__ + +#include "opencv2/cudaarithm.hpp" + +#include + +namespace cv { namespace cuda { + +class LookUpTableImpl : public LookUpTable +{ +public: + LookUpTableImpl(InputArray lut); + ~LookUpTableImpl(); + + void transform(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) CV_OVERRIDE; + +private: + GpuMat d_lut; + cudaTextureObject_t texLutTableObj; + bool cc30; +}; + +} } + +#endif // __CUDAARITHM_LUT_HPP__ From 8c8715c4ddb762703b9ef285644693b10e0601a1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 13 Mar 2019 17:14:03 +0300 Subject: [PATCH 08/10] fix static analysis issues --- modules/calib3d/src/fisheye.cpp | 5 +++-- modules/core/src/ocl.cpp | 2 ++ modules/imgproc/src/canny.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index d174c1427b..5fe6b2a08d 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -104,8 +104,9 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints Vec4d k = _D.depth() == CV_32F ? (Vec4d)*_D.getMat().ptr(): *_D.getMat().ptr(); + const bool isJacobianNeeded = jacobian.needed(); JacobianRow *Jn = 0; - if (jacobian.needed()) + if (isJacobianNeeded) { int nvars = 2 + 2 + 1 + 4 + 3 + 3; // f, c, alpha, k, om, T, jacobian.create(2*(int)n, nvars, CV_64F); @@ -153,7 +154,7 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints else xpd[i] = final_point; - if (jacobian.needed()) + if (isJacobianNeeded) { //Vec3d Xi = pdepth == CV_32F ? (Vec3d)Xf[i] : Xd[i]; //Vec3d Y = aff*Xi; diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 3b9e137a1a..745d034373 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -4435,6 +4435,7 @@ public: : size_(size), originPtr_(ptr), alignment_(alignment), ptr_(ptr), allocatedPtr_(NULL) { CV_DbgAssert((alignment & (alignment - 1)) == 0); // check for 2^n + CV_DbgAssert(!readAccess || ptr); if (((size_t)ptr_ & (alignment - 1)) != 0) { allocatedPtr_ = new uchar[size_ + alignment - 1]; @@ -4488,6 +4489,7 @@ public: : size_(rows*step), originPtr_(ptr), alignment_(alignment), ptr_(ptr), allocatedPtr_(NULL), rows_(rows), cols_(cols), step_(step) { CV_DbgAssert((alignment & (alignment - 1)) == 0); // check for 2^n + CV_DbgAssert(!readAccess || ptr != NULL); if (ptr == 0 || ((size_t)ptr_ & (alignment - 1)) != 0) { allocatedPtr_ = new uchar[size_ + extrabytes + alignment - 1]; diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 89eac241c1..355cf37447 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -360,6 +360,8 @@ public: { CV_TRACE_FUNCTION(); + CV_DbgAssert(cn > 0); + Mat dx, dy; AutoBuffer dxMax(0), dyMax(0); std::deque stack, borderPeaksLocal; From 9cca066ee81edde4f5599adfb7977afe3d5b57be Mon Sep 17 00:00:00 2001 From: rpici Date: Wed, 13 Mar 2019 09:42:47 -0500 Subject: [PATCH 09/10] Fix bug in test_tiff.cpp The big endian data in the tiff_sample_data array was never being tested. This could be observed by e.g. changing the 9th byte in the big endian data from 0xde to something that should fail the test, e.g. 0xdd, and the test would still pass even though it should fail. --- modules/imgcodecs/test/test_tiff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgcodecs/test/test_tiff.cpp b/modules/imgcodecs/test/test_tiff.cpp index 0c9d7ae908..76a2cd4cd4 100644 --- a/modules/imgcodecs/test/test_tiff.cpp +++ b/modules/imgcodecs/test/test_tiff.cpp @@ -76,7 +76,7 @@ TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian) // 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)); + ASSERT_EQ((size_t)1, fwrite(tiff_sample_data[i], 86, 1, fp)); fclose(fp); Mat img = imread(filename, IMREAD_UNCHANGED); From 8158e5b7a0000ff1a6f7d65763d2b1605844ba46 Mon Sep 17 00:00:00 2001 From: Richard Veale Date: Thu, 14 Mar 2019 02:53:59 +0900 Subject: [PATCH 10/10] Merge pull request #13695 from flyingfalling:3.4 * Fixed bug that made cuda::filter give corrupted output when different filters called in different threads. This was due to use of global texture variable shared by all filters. * REV: fixed tab issue for opencv coding style... --- modules/cudafilters/src/cuda/filter2d.cu | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/cudafilters/src/cuda/filter2d.cu b/modules/cudafilters/src/cuda/filter2d.cu index 67d75d4c78..e37e91dd2f 100644 --- a/modules/cudafilters/src/cuda/filter2d.cu +++ b/modules/cudafilters/src/cuda/filter2d.cu @@ -77,17 +77,17 @@ namespace cv { namespace cuda { namespace device template class Brd> struct Filter2DCaller; #define IMPLEMENT_FILTER2D_TEX_READER(type) \ - texture< type , cudaTextureType2D, cudaReadModeElementType> tex_filter2D_ ## type (0, cudaFilterModePoint, cudaAddressModeClamp); \ struct tex_filter2D_ ## type ## _reader \ { \ + PtrStepSz dat; \ typedef type elem_type; \ typedef int index_type; \ const int xoff; \ const int yoff; \ - tex_filter2D_ ## type ## _reader (int xoff_, int yoff_) : xoff(xoff_), yoff(yoff_) {} \ + tex_filter2D_ ## type ## _reader (PtrStepSz dat_, int xoff_, int yoff_) : dat(dat_), xoff(xoff_), yoff(yoff_) {} \ __device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const \ { \ - return tex2D(tex_filter2D_ ## type , x + xoff, y + yoff); \ + return dat(y + yoff, x + xoff ); \ } \ }; \ template class Brd> struct Filter2DCaller< type , D, Brd> \ @@ -98,8 +98,7 @@ namespace cv { namespace cuda { namespace device typedef typename TypeVec::cn>::vec_type work_type; \ dim3 block(16, 16); \ dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \ - bindTexture(&tex_filter2D_ ## type , srcWhole); \ - tex_filter2D_ ## type ##_reader texSrc(xoff, yoff); \ + tex_filter2D_ ## type ##_reader texSrc(srcWhole, xoff, yoff); \ Brd brd(dst.rows, dst.cols, VecTraits::make(borderValue)); \ BorderReader< tex_filter2D_ ## type ##_reader, Brd > brdSrc(texSrc, brd); \ filter2D<<>>(brdSrc, dst, kernel, kWidth, kHeight, anchorX, anchorY); \