mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
name: arm64 build checks
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependency packages
|
||||
run: |
|
||||
sudo sed -i -E 's|^deb ([^ ]+) (.*)$|deb [arch=amd64] \1 \2\ndeb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ \2|' /etc/apt/sources.list
|
||||
sudo dpkg --add-architecture arm64
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
crossbuild-essential-arm64 \
|
||||
git \
|
||||
cmake \
|
||||
libpython3-dev:arm64 \
|
||||
python-numpy \
|
||||
python3-numpy
|
||||
|
||||
- name: Fetch opencv_contrib
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/opencv/opencv_contrib.git ../opencv_contrib
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DPYTHON3_INCLUDE_PATH=/usr/include/python3.6m/ \
|
||||
-DPYTHON3_LIBRARIES=/usr/lib/aarch64-linux-gnu/libpython3.6m.so \
|
||||
-DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../platforms/linux/aarch64-gnu.toolchain.cmake \
|
||||
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
|
||||
../
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
make -j$(nproc --all)
|
||||
@@ -1,27 +0,0 @@
|
||||
name: lint_python
|
||||
on: workflow_dispatch
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
jobs:
|
||||
lint_python:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: pip install --upgrade pip wheel
|
||||
- run: pip install bandit black codespell flake8 flake8-2020 flake8-bugbear
|
||||
flake8-comprehensions isort mypy pytest pyupgrade safety
|
||||
- run: bandit --recursive --skip B101 . || true # B101 is assert statements
|
||||
- run: black --check . || true
|
||||
- run: codespell || true # --ignore-words-list="" --skip="*.css,*.js,*.lock"
|
||||
- run: flake8 . --count --select=E9,F63,F7 --show-source --statistics
|
||||
- run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88
|
||||
--show-source --statistics
|
||||
- run: isort --check-only --profile black . || true
|
||||
- run: pip install -r requirements.txt || pip install --editable . || true
|
||||
- run: mkdir --parents --verbose .mypy_cache
|
||||
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
|
||||
- run: pytest . || true
|
||||
- run: pytest --doctest-modules . || true
|
||||
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
|
||||
- run: safety check
|
||||
Vendored
+5
-5
@@ -2,7 +2,7 @@ function(download_ippicv root_var)
|
||||
set(${root_var} "" PARENT_SCOPE)
|
||||
|
||||
# Commit SHA in the opencv_3rdparty repo
|
||||
set(IPPICV_COMMIT "c934a2a15a6df020446ac3dfa07e3acf72b63a8f")
|
||||
set(IPPICV_COMMIT "e6154bd971073bc60f7141e5373108501b0310a9")
|
||||
# Define actual ICV versions
|
||||
if(APPLE)
|
||||
set(IPPICV_COMMIT "0cc4aa06bf2bef4b05d237c69a5a96b9cd0cb85a")
|
||||
@@ -14,8 +14,8 @@ function(download_ippicv root_var)
|
||||
set(OPENCV_ICV_PLATFORM "linux")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx")
|
||||
if(X86_64)
|
||||
set(OPENCV_ICV_NAME "ippicv_2022.2.0_lnx_intel64_20250730_general.tgz")
|
||||
set(OPENCV_ICV_HASH "55d18247d8ef707f009b94f69d77b948")
|
||||
set(OPENCV_ICV_NAME "ippicv_2022.3.0_lnx_intel64_20250919_general.tgz")
|
||||
set(OPENCV_ICV_HASH "cbd5a1cc19de8a863b71d03f03245b10")
|
||||
else()
|
||||
if(ANDROID)
|
||||
set(IPPICV_COMMIT "c7c6d527dde5fee7cb914ee9e4e20f7436aab3a1")
|
||||
@@ -31,8 +31,8 @@ function(download_ippicv root_var)
|
||||
set(OPENCV_ICV_PLATFORM "windows")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_win")
|
||||
if(X86_64)
|
||||
set(OPENCV_ICV_NAME "ippicv_2022.2.0_win_intel64_20250730_general.zip")
|
||||
set(OPENCV_ICV_HASH "7c0973976ab0716bc33f03a76a50017f")
|
||||
set(OPENCV_ICV_NAME "ippicv_2022.3.0_win_intel64_20250919_general.zip")
|
||||
set(OPENCV_ICV_HASH "27575d20636f76cb81dcf3898cfe6837")
|
||||
else()
|
||||
set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
|
||||
set(OPENCV_ICV_NAME "ippicv_2021.12.0_win_ia32_20240425_general.zip")
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ OCV_OPTION(BUILD_TBB "Download and build TBB from source" (ANDROI
|
||||
OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" (NOT MINGW OR OPENCV_FORCE_3RDPARTY_BUILD) IF (X86_64 OR X86) AND NOT WINRT )
|
||||
OCV_OPTION(BUILD_ITT "Build Intel ITT from source"
|
||||
(NOT MINGW OR OPENCV_FORCE_3RDPARTY_BUILD)
|
||||
IF (X86_64 OR X86 OR ARM OR AARCH64 OR PPC64 OR PPC64LE) AND NOT WINRT AND NOT APPLE_FRAMEWORK
|
||||
IF (X86_64 OR X86 OR ARM OR AARCH64 OR PPC64 OR PPC64LE OR LOONGARCH64) AND NOT WINRT AND NOT APPLE_FRAMEWORK
|
||||
)
|
||||
OCV_OPTION(BUILD_CLAPACK "Build CLapack from source" (((WIN32 OR ANDROID) AND NOT APPLE) OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/footer.html
|
||||
HTML_STYLESHEET =
|
||||
HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/doxygen-awesome.css @CMAKE_CURRENT_SOURCE_DIR@/custom.css
|
||||
HTML_EXTRA_FILES = @CMAKE_DOXYGEN_HTML_FILES@
|
||||
HTML_COLORSTYLE = LIGHT
|
||||
HTML_COLORSTYLE = TOGGLE
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
|
||||
@@ -71,7 +71,7 @@ For example, you can create a cv.Mat from an image by cv.imread.
|
||||
@note Because image loading is asynchronous, you need to put cv.Mat creation inside the `onload` callback.
|
||||
|
||||
@code{.js}
|
||||
imgElement.onload = await function() {
|
||||
imgElement.onload = async function() {
|
||||
cv = (cv instanceof Promise) ? await cv : cv;
|
||||
let mat = cv.imread(imgElement);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ Camera calibration With OpenCV {#tutorial_camera_calibration}
|
||||
| Compatibility | OpenCV >= 4.0 |
|
||||
|
||||
|
||||
Cameras have been around for a long-long time. However, with the introduction of the cheap *pinhole*
|
||||
Cameras have been around for a very long time. However, with the introduction of the cheap *pinhole*
|
||||
cameras in the late 20th century, they became a common occurrence in our everyday life.
|
||||
Unfortunately, this cheapness comes with its price: significant distortion. Luckily, these are
|
||||
Unfortunately, this low cost comes with a trade-off: significant distortion. Luckily, these are
|
||||
constants and with a calibration and some remapping we can correct this. Furthermore, with
|
||||
calibration you may also determine the relation between the camera's natural units (pixels) and the
|
||||
real world units (for example millimeters).
|
||||
@@ -22,8 +22,10 @@ real world units (for example millimeters).
|
||||
Theory
|
||||
------
|
||||
|
||||
For the distortion OpenCV takes into account the radial and tangential factors. For the radial
|
||||
factor one uses the following formula:
|
||||
For distortion, OpenCV takes into account both radial and tangential factors. For the radial
|
||||
factor one uses the following formulas:
|
||||
|
||||
\f[r^2 = x^2 + y^2\f]
|
||||
|
||||
\f[x_{distorted} = x( 1 + k_1 r^2 + k_2 r^4 + k_3 r^6) \\
|
||||
y_{distorted} = y( 1 + k_1 r^2 + k_2 r^4 + k_3 r^6)\f]
|
||||
@@ -64,10 +66,10 @@ objects. Currently OpenCV supports three types of objects for calibration:
|
||||
- Symmetrical circle pattern
|
||||
- Asymmetrical circle pattern
|
||||
|
||||
Basically, you need to take snapshots of these patterns with your camera and let OpenCV find them.
|
||||
In practice, you need to capture multiple images of these patterns using your camera and let OpenCV find them.
|
||||
Each found pattern results in a new equation. To solve the equation you need at least a
|
||||
predetermined number of pattern snapshots to form a well-posed equation system. This number is
|
||||
higher for the chessboard pattern and less for the circle ones. For example, in theory the
|
||||
higher for the chessboard pattern and lower for circle-based patterns.For example, in theory the
|
||||
chessboard pattern requires at least two snapshots. However, in practice we have a good amount of
|
||||
noise present in our input images, so for good results you will probably need at least 10 good
|
||||
snapshots of the input pattern in different positions.
|
||||
@@ -148,8 +150,8 @@ Explanation
|
||||
is defined in squares, but detection result is list of inner corners and that's why is smaller
|
||||
by 1 in both dimensions.
|
||||
|
||||
Then again in case of cameras we only take camera images when an input delay time is passed.
|
||||
This is done in order to allow user moving the chessboard around and getting different images.
|
||||
In the case of live cameras, we only capture images when an input delay time is passed.
|
||||
This is done to allow the user to move the chessboard around and getting different images.
|
||||
Similar images result in similar equations, and similar equations at the calibration step will
|
||||
form an ill-posed problem, so the calibration will fail. For square images the positions of the
|
||||
corners are only approximate. We may improve this by calling the @ref cv::cornerSubPix function.
|
||||
@@ -160,6 +162,7 @@ Explanation
|
||||
visualization feedback purposes we will draw the found points on the input image using @ref
|
||||
cv::findChessboardCorners function.
|
||||
@snippet samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp pattern_found
|
||||
|
||||
-# **Show state and result to the user, plus command line control of the application**
|
||||
|
||||
This part shows text output on the image.
|
||||
@@ -170,6 +173,7 @@ Explanation
|
||||
Then we show the image and wait for an input key and if this is *u* we toggle the distortion removal,
|
||||
if it is *g* we start again the detection process, and finally for the *ESC* key we quit the application:
|
||||
@snippet samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp await_input
|
||||
|
||||
-# **Show the distortion removal for the images too**
|
||||
|
||||
When you work with an image list it is not
|
||||
|
||||
@@ -317,7 +317,7 @@ Following formats can be read by OpenCV without help of any third-party library:
|
||||
| [PFM](https://en.wikipedia.org/wiki/Netpbm#File_formats) | `WITH_IMGCODEC_PFM` | _ON_ |
|
||||
| [GIF](https://en.wikipedia.org/wiki/GIF) | `WITH_IMGCODEC_GIF` | _ON_ |
|
||||
|
||||
### PNG, JPEG, TIFF, WEBP, JPEG 2000, EXR, JPEG XL support
|
||||
### PNG, JPEG, TIFF, WEBP, JPEG 2000, EXR, JPEG XL, AVIF support
|
||||
|
||||
| Formats | Library | Option | Default | Force build own |
|
||||
| --------| ------- | ------ | ------- | --------------- |
|
||||
@@ -331,13 +331,18 @@ Following formats can be read by OpenCV without help of any third-party library:
|
||||
|^| [JasPer](https://en.wikipedia.org/wiki/JasPer) | `WITH_JASPER` | _ON_ (see note) | `BUILD_JASPER` |
|
||||
| [OpenEXR](https://en.wikipedia.org/wiki/OpenEXR) || `WITH_OPENEXR` | _ON_ | `BUILD_OPENEXR` |
|
||||
| [JPEG XL](https://en.wikipedia.org/wiki/JPEG_XL) || `WITH_JPEGXL` | _ON_ | Not supported. (see note) |
|
||||
| [AVIF](https://en.wikipedia.org/wiki/AVIF) || `WITH_AVIF` | _ON_ | Not supported. (see note) |
|
||||
|
||||
All libraries required to read images in these formats are included into OpenCV and will be built automatically if not found at the configuration stage. Corresponding `BUILD_*` options will force building and using own libraries, they are enabled by default on some platforms, e.g. Windows.
|
||||
Most library source codes required to read/write images in these formats are bundled into OpenCV and will be built automatically if not found at the configuration stage
|
||||
(except for some codecs that require external libraries, e.g. JPEG XL and AVIF).
|
||||
Corresponding BUILD_* options will force building and using the bundled libraries; they are enabled by default on some platforms, e.g. Windows.
|
||||
|
||||
@note (All) Only one library for each image format can be enabled(e.g. In order to use JasPer for JPEG 2000 format, OpenJPEG must be disabled).
|
||||
@note (JPEG 2000) OpenJPEG have higher priority than JasPer which is deprecated.
|
||||
@note (JPEG XL) OpenCV doesn't contain libjxl source code, so `BUILD_JPEGXL` is not supported.
|
||||
@note (EXR) OpenCV 5 doesn't contain OpenEXR source code, so `BUILD_OPENEXR` is not supported.
|
||||
@note (JPEG XL) OpenCV doesn't contain libjxl source code, so `BUILD_JPEGXL` is not supported. Users must provide a system-wide installation of libjxl.
|
||||
@note (AVIF) OpenCV doesn't contain libavif source code, so `BUILD_AVIF` is not supported. Users must provide a system-wide installation of libavif.
|
||||
|
||||
@warning OpenEXR ver 2.2 or earlier cannot be used in combination with C++17 or later. In this case, updating OpenEXR ver 2.3.0 or later is required.
|
||||
|
||||
|
||||
@@ -25,4 +25,6 @@
|
||||
|
||||
#define CV_INSTRUMENT_FUN_IPP(FUN, ...) ((FUN)(__VA_ARGS__))
|
||||
|
||||
#define CV_HAL_CHECK_USE_IPP() if(!cv::ipp::useIPP()) return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
int ipp_hal_polarToCart32f(const float* mag, const float* angle, float* x, float* y, int len, bool angleInDegrees)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
const bool isInPlace = (x == mag) || (x == angle) || (y == mag) || (y == angle);
|
||||
if (isInPlace || angleInDegrees)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -21,6 +22,7 @@ int ipp_hal_polarToCart32f(const float* mag, const float* angle, float* x, float
|
||||
|
||||
int ipp_hal_polarToCart64f(const double* mag, const double* angle, double* x, double* y, int len, bool angleInDegrees)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
const bool isInPlace = (x == mag) || (x == angle) || (y == mag) || (y == angle);
|
||||
if (isInPlace || angleInDegrees)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -196,6 +196,7 @@ static int ipp_meanStdDev(const uchar* src_data, size_t src_step, int width, int
|
||||
int ipp_hal_meanStdDev(const uchar* src_data, size_t src_step, int width, int height, int src_type,
|
||||
double* mean_val, double* stddev_val, uchar* mask, size_t mask_step)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
if (stddev_val)
|
||||
{
|
||||
return ipp_meanStdDev(src_data, src_step, width, height, src_type, mean_val, stddev_val, mask, mask_step);
|
||||
|
||||
@@ -160,6 +160,7 @@ typedef IppStatus (*IppMinMaxSelector)(const void* pSrc, int srcStep, IppiSize s
|
||||
int ipp_hal_minMaxIdxMaskStep(const uchar* src_data, size_t src_step, int width, int height, int depth,
|
||||
double* _minVal, double* _maxVal, int* _minIdx, int* _maxIdx, uchar* mask, size_t mask_step)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
#if IPP_VERSION_X100 < 201800
|
||||
// cv::minMaxIdx problem with NaN input
|
||||
// Disable 32F processing only
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
int ipp_hal_norm(const uchar* src, size_t src_step, const uchar* mask, size_t mask_step,
|
||||
int width, int height, int type, int norm_type, double* result)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
if( mask )
|
||||
{
|
||||
IppiSize sz = { width, height };
|
||||
@@ -131,6 +132,7 @@ int ipp_hal_norm(const uchar* src, size_t src_step, const uchar* mask, size_t ma
|
||||
int ipp_hal_normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2_step, const uchar* mask,
|
||||
size_t mask_step, int width, int height, int type, int norm_type, double* result)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
if( norm_type & cv::NORM_RELATIVE )
|
||||
{
|
||||
norm_type &= cv::NORM_TYPE_MASK;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
int ipp_hal_sum(const uchar *src_data, size_t src_step, int src_type, int width, int height, double *result)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
int cn = CV_MAT_CN(src_type);
|
||||
if (cn > 4)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace cv
|
||||
int ipp_hal_transpose2d(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int src_width,
|
||||
int src_height, int element_size)
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
typedef IppStatus (CV_STDCALL * IppiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * IppiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
IppiTranspose ippiTranspose = nullptr;
|
||||
@@ -99,6 +100,7 @@ int ipp_hal_flip(int src_type, const uchar* src_data, size_t src_step, int src_w
|
||||
uchar* dst_data, size_t dst_step, int flip_mode)
|
||||
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
int64_t total = src_step*src_height*CV_ELEM_SIZE(src_type);
|
||||
// Details: https://github.com/opencv/opencv/issues/12943
|
||||
if (flip_mode <= 0 /* swap rows */
|
||||
|
||||
@@ -73,6 +73,7 @@ private:
|
||||
int ipp_hal_warpAffine(int src_type, 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, const double M[6], int interpolation, int borderType, const double borderValue[4])
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
//CV_INSTRUMENT_REGION_IPP();
|
||||
|
||||
IppiInterpolationType ippInter = ippiGetInterpolation(interpolation);
|
||||
@@ -324,6 +325,7 @@ private:
|
||||
int ipp_hal_warpPerspective(int src_type, 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, const double M[9], int interpolation, int borderType, const double borderValue[4])
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
//CV_INSTRUMENT_REGION_IPP();
|
||||
|
||||
if (src_height <= 1 || src_width <= 1)
|
||||
@@ -505,6 +507,7 @@ int ipp_hal_remap32f(int src_type, const uchar *src_data, size_t src_step, int s
|
||||
float *mapx, size_t mapx_step, float *mapy, size_t mapy_step,
|
||||
int interpolation, int border_type, const double border_value[4])
|
||||
{
|
||||
CV_HAL_CHECK_USE_IPP();
|
||||
if (!((interpolation == cv::INTER_LINEAR || interpolation == cv::INTER_CUBIC || interpolation == cv::INTER_NEAREST) &&
|
||||
(border_type == cv::BORDER_CONSTANT || border_type == cv::BORDER_TRANSPARENT)))
|
||||
{
|
||||
|
||||
@@ -137,7 +137,7 @@ static inline double dotProd_32s(const int *a, const int *b, int len) {
|
||||
auto va = __riscv_vle32_v_i32m4(a + j, vl);
|
||||
auto vb = __riscv_vle32_v_i32m4(b + j, vl);
|
||||
|
||||
s = __riscv_vfadd(s, __riscv_vfcvt_f(__riscv_vwmul(va, vb, vl), vl), vl);
|
||||
s = __riscv_vfadd_vv_f64m8_tu(s, s, __riscv_vfcvt_f(__riscv_vwmul(va, vb, vl), vl), vl);
|
||||
}
|
||||
r = __riscv_vfmv_f(__riscv_vfredosum(s, __riscv_vfmv_v_f_f64m1(0.f, __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m8()));
|
||||
|
||||
@@ -160,7 +160,7 @@ static inline double dotProd_32f(const float *a, const float *b, int len) {
|
||||
auto va = __riscv_vle32_v_f32m4(a + j, vl);
|
||||
auto vb = __riscv_vle32_v_f32m4(b + j, vl);
|
||||
|
||||
s = __riscv_vfmacc(s, va, vb, vl);
|
||||
s = __riscv_vfmacc_vv_f32m4_tu(s, va, vb, vl);
|
||||
}
|
||||
r += (double)__riscv_vfmv_f(__riscv_vfredusum(s, __riscv_vfmv_v_f_f32m1(0.f, __riscv_vsetvlmax_e32m1()), __riscv_vsetvlmax_e32m4()));
|
||||
|
||||
|
||||
@@ -915,6 +915,22 @@ CV_EXPORTS_W void composeRT( InputArray rvec1, InputArray tvec1,
|
||||
|
||||
/** @brief Projects 3D points to an image plane.
|
||||
|
||||
The function computes the 2D projections of 3D points to the image plane, given intrinsic and
|
||||
extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
|
||||
derivatives of image points coordinates (as functions of all the input parameters) with respect to
|
||||
the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
|
||||
optimization in @ref calibrateCamera, @ref solvePnP, and @ref stereoCalibrate. The function itself
|
||||
can also be used to compute a re-projection error, given the current intrinsic and extrinsic
|
||||
parameters.
|
||||
|
||||
@note **Coordinate Systems:**
|
||||
- **Input (`objectPoints`)**: 3D points in the **world coordinate frame**.
|
||||
- **Output (`imagePoints`)**: 2D projections in **pixel coordinates** of the image plane, with distortion applied.
|
||||
The coordinates \f$(u, v)\f$ are measured in pixels from the top-left corner of the image.
|
||||
|
||||
The transformation chain is: World coordinates → Camera coordinates (via rvec/tvec) → Normalized camera coordinates
|
||||
→ Distortion applied → Pixel coordinates (via cameraMatrix).
|
||||
|
||||
@param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
|
||||
1-channel or 1xN/Nx1 3-channel (or vector\<Point3f\> ), where N is the number of points in the view.
|
||||
@param rvec The rotation vector (@ref Rodrigues) that, together with tvec, performs a change of
|
||||
@@ -923,7 +939,7 @@ basis from world to camera coordinate system, see @ref calibrateCamera for detai
|
||||
@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ .
|
||||
@param distCoeffs Input vector of distortion coefficients
|
||||
\f$\distcoeffs\f$ . If the vector is empty, the zero distortion coefficients are assumed.
|
||||
@param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
|
||||
@param imagePoints Output array of image points in **pixel coordinates**, 1xN/Nx1 2-channel, or
|
||||
vector\<Point2f\> .
|
||||
@param jacobian Optional output 2Nx(10+\<numDistCoeffs\>) jacobian matrix of derivatives of image
|
||||
points with respect to components of the rotation vector, translation vector, focal lengths,
|
||||
@@ -933,14 +949,6 @@ components of the jacobian are returned via different output parameters.
|
||||
function assumes that the aspect ratio (\f$f_x / f_y\f$) is fixed and correspondingly adjusts the
|
||||
jacobian matrix.
|
||||
|
||||
The function computes the 2D projections of 3D points to the image plane, given intrinsic and
|
||||
extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
|
||||
derivatives of image points coordinates (as functions of all the input parameters) with respect to
|
||||
the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
|
||||
optimization in @ref calibrateCamera, @ref solvePnP, and @ref stereoCalibrate. The function itself
|
||||
can also be used to compute a re-projection error, given the current intrinsic and extrinsic
|
||||
parameters.
|
||||
|
||||
@note By setting rvec = tvec = \f$[0, 0, 0]\f$, or by setting cameraMatrix to a 3x3 identity matrix,
|
||||
or by passing zero distortion coefficients, one can get various useful partial cases of the
|
||||
function. This means, one can compute the distorted coordinates for a sparse set of points or apply
|
||||
@@ -2512,7 +2520,17 @@ point coordinates out of the normalized distorted point coordinates ("normalized
|
||||
coordinates do not depend on the camera matrix).
|
||||
|
||||
The function can be used for both a stereo camera head or a monocular camera (when R is empty).
|
||||
@param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
|
||||
|
||||
@note **Coordinate Systems:**
|
||||
- **Input (`src`)**: Points are expected in **pixel coordinates** of the distorted image, i.e.,
|
||||
coordinates \f$(u, v)\f$ measured in pixels from the top-left corner of the image.
|
||||
- **Output (`dst`)**: The coordinate system of output points depends on parameter `P`:
|
||||
- If `P` is provided (not empty): Output points are in **pixel coordinates** of the rectified/undistorted image plane, using the camera matrix `P`.
|
||||
- If `P` is empty or identity: Output points are in **normalized camera coordinates** (also called "normalized image coordinates"),
|
||||
which are dimensionless coordinates \f$(x, y)\f$ in the camera's focal plane, related to pixel coordinates by:
|
||||
\f$x = (u - c_x) / f_x\f$ and \f$y = (v - c_y) / f_y\f$. These normalized coordinates are independent of the camera's intrinsic parameters and are useful for 3D reconstruction or epipolar geometry.
|
||||
|
||||
@param src Observed point coordinates in **pixel coordinates** of the distorted image, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
|
||||
vector\<Point2f\> ).
|
||||
@param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector\<Point2f\> ) after undistortion and reverse perspective
|
||||
transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
|
||||
@@ -2523,7 +2541,7 @@ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion
|
||||
@param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
|
||||
#stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
|
||||
@param P New camera matrix (3x3) or new projection matrix (3x4) \f$\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\f$. P1 or P2 computed by
|
||||
#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
|
||||
#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used and output will be in normalized coordinates.
|
||||
@param criteria termination criteria for the iterative point undistortion algorithm
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
@@ -2604,17 +2622,40 @@ the number of points in the view.
|
||||
*/
|
||||
CV_EXPORTS_W void distortPoints(InputArray undistorted, OutputArray distorted, InputArray Kundistorted, InputArray K, InputArray D, double alpha = 0);
|
||||
|
||||
/** @brief Undistorts 2D points using fisheye model
|
||||
/** @brief Undistorts 2D points using fisheye camera model
|
||||
|
||||
@param distorted Array of object points, 1xN/Nx1 2-channel (or vector\<Point2f\> ), where N is the
|
||||
number of points in the view.
|
||||
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
|
||||
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
|
||||
This function performs undistortion for fisheye camera models, which use a different distortion model
|
||||
compared to the standard pinhole camera model used by #undistortPoints. The fisheye model is suitable
|
||||
for wide-angle cameras.
|
||||
|
||||
The function transforms points from the distorted fisheye image to undistorted coordinates, optionally
|
||||
applying a rectification transformation (R) and projecting to a new image plane (P).
|
||||
|
||||
@note **Coordinate Systems:**
|
||||
- **Input (`distorted`)**: Points are expected in **pixel coordinates** of the distorted fisheye image,
|
||||
i.e., coordinates measured in pixels from the top-left corner of the image.
|
||||
- **Output (`undistorted`)**: The coordinate system depends on parameter `P`:
|
||||
- If `P` is provided (not empty): Output points are in **pixel coordinates** of the rectified/undistorted
|
||||
image plane, using the camera matrix `P`.
|
||||
- If `P` is empty or identity: Output points are in **normalized camera coordinates** (normalized image coordinates),
|
||||
which are dimensionless coordinates in the camera's focal plane, independent of intrinsic parameters.
|
||||
|
||||
@note **Fisheye vs. Standard Model:**
|
||||
Use this function (#fisheye::undistortPoints) for fisheye cameras (wide-angle lenses).
|
||||
For standard pinhole cameras, use #undistortPoints instead. The fisheye model uses a different distortion
|
||||
parameterization (4 coefficients) compared to the standard model (4-14 coefficients).
|
||||
|
||||
@param distorted Array of distorted point coordinates in **pixel coordinates** of the fisheye image,
|
||||
1xN/Nx1 2-channel (or vector\<Point2f\> ), where N is the number of points in the view.
|
||||
@param K Camera intrinsic matrix \f$\cameramatrix{K}\f$ of the fisheye camera.
|
||||
@param D Input vector of fisheye distortion coefficients \f$\distcoeffsfisheye\f$ (must contain exactly 4 coefficients).
|
||||
@param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
|
||||
1-channel or 1x1 3-channel
|
||||
@param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
|
||||
@param criteria Termination criteria
|
||||
@param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector\<Point2f\> .
|
||||
1-channel or 1x1 3-channel. If empty, the identity transformation is used.
|
||||
@param P New camera intrinsic matrix (3x3) or new projection matrix (3x4). If empty or identity,
|
||||
output will be in normalized camera coordinates.
|
||||
@param criteria Termination criteria for the iterative undistortion algorithm.
|
||||
@param undistorted Output array of undistorted image points, 1xN/Nx1 2-channel, or vector\<Point2f\> .
|
||||
The coordinate system depends on parameter P (see above).
|
||||
*/
|
||||
CV_EXPORTS_W void undistortPoints(InputArray distorted, OutputArray undistorted,
|
||||
InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray(),
|
||||
|
||||
@@ -1740,7 +1740,7 @@ static inline unsigned sacCalcIterBound(double confidence,
|
||||
* \[ k = \frac{\log{(1-confidence)}}{\log{(1-inlierRate**sampleSize)}} \]
|
||||
*/
|
||||
|
||||
double atLeastOneOutlierProbability = 1.-pow(inlierRate, (double)sampleSize);
|
||||
double atLeastOneOutlierProbability = 1.-std::pow(inlierRate, (double)sampleSize);
|
||||
|
||||
/**
|
||||
* There are two special cases: When argument to log() is 0 and when it is 1.
|
||||
|
||||
@@ -508,7 +508,7 @@ static void undistortPointsInternal( const Mat& _src, Mat& _dst, const Mat& _cam
|
||||
double x_proj = xd*fx + cx;
|
||||
double y_proj = yd*fy + cy;
|
||||
|
||||
error = sqrt( pow(x_proj - u, 2) + pow(y_proj - v, 2) );
|
||||
error = sqrt( std::pow(x_proj - u, 2) + std::pow(y_proj - v, 2) );
|
||||
}
|
||||
if (error > prevError) {
|
||||
alpha *= .5;
|
||||
|
||||
@@ -68,7 +68,7 @@ class NormTransform : public Algorithm {
|
||||
public:
|
||||
/*
|
||||
* @norm_points is output matrix of size pts_size x 4
|
||||
* @sample constains indices of points
|
||||
* @sample contains indices of points
|
||||
* @sample_number is number of used points in sample <0; sample_number)
|
||||
* @T1, T2 are output transformation matrices
|
||||
*/
|
||||
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
const int num_f_inliers_of_h_outliers = getNonPlanarSupport(Mat(F), num_models_used_so_far >= MAX_MODELS_TO_TEST, non_planar_support);
|
||||
if (non_planar_support < num_f_inliers_of_h_outliers) {
|
||||
non_planar_support = num_f_inliers_of_h_outliers;
|
||||
const double predicted_iters = log_conf / log(1 - pow(static_cast<double>
|
||||
const double predicted_iters = log_conf / log(1 - std::pow(static_cast<double>
|
||||
(getNonPlanarSupport(Mat(F), non_planar_pts, num_non_planar_pts)) / num_non_planar_pts, 2));
|
||||
if (use_preemptive && ! std::isinf(predicted_iters) && predicted_iters < max_iters)
|
||||
max_iters = static_cast<int>(predicted_iters);
|
||||
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
DoF = DoF_; C = C_;
|
||||
max_sigma = max_sigma_;
|
||||
squared_sigma_max_2 = max_sigma * max_sigma * 2.0;
|
||||
one_over_sigma = C * pow(2.0, (DoF - 1.0) * 0.5) / max_sigma;
|
||||
one_over_sigma = C * std::pow(2, (DoF - 1.0) * 0.5) / max_sigma;
|
||||
max_sigma_sqr = squared_sigma_max_2 * 0.5;
|
||||
rescale_err = scale_of_stored_gammas / squared_sigma_max_2;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ public:
|
||||
int getInliersWeights (const std::vector<float> &errors, std::vector<int> &inliers, std::vector<double> &weights, double thr_sqr) const override {
|
||||
const auto _max_sigma = thr_sqr;
|
||||
const auto _squared_sigma_max_2 = _max_sigma * _max_sigma * 2.0;
|
||||
const auto _one_over_sigma = C * pow(2.0, (DoF - 1.0) * 0.5) / _max_sigma;
|
||||
const auto _one_over_sigma = C * std::pow(2, (DoF - 1.0) * 0.5) / _max_sigma;
|
||||
const auto _max_sigma_sqr = _squared_sigma_max_2 * 0.5;
|
||||
const auto _rescale_err = scale_of_stored_gammas / _squared_sigma_max_2;
|
||||
return getInliersWeights(errors, inliers, weights, _one_over_sigma, _rescale_err, _max_sigma_sqr);
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
const auto maximum_sigma_2 = (float) (maximum_sigma * maximum_sigma);
|
||||
maximum_sigma_2_per_2 = maximum_sigma_2 / 2.f;
|
||||
const auto maximum_sigma_2_times_2 = maximum_sigma_2 * 2.f;
|
||||
two_ad_dof_plus_one_per_maximum_sigma = pow(2.0, (DoF + 1.0)*.5)/maximum_sigma;
|
||||
two_ad_dof_plus_one_per_maximum_sigma = std::pow(2, (DoF + 1.0)*.5)/maximum_sigma;
|
||||
rescale_err = gamma_generator->getScaleOfGammaCompleteValues() / maximum_sigma_2_times_2;
|
||||
stored_incomplete_gamma_number_min1 = static_cast<unsigned int>(gamma_generator->getTableSize()-1);
|
||||
|
||||
|
||||
@@ -1099,14 +1099,14 @@ bool UniversalRANSAC::run(Ptr<RansacOutput> &ransac_output) {
|
||||
_quality->getInliers(best_model, temp_inliers));
|
||||
// quick test on lambda from all inliers (= upper bound of independent inliers)
|
||||
// if model with independent inliers is not random for Poisson with all inliers then it is not random using independent inliers too
|
||||
if (pow(Utils::getPoissonCDF(lambda_non_random_all_inliers, non_random_inls_best_model), num_total_tested_models) < 0.9999) {
|
||||
if (std::pow(Utils::getPoissonCDF(lambda_non_random_all_inliers, non_random_inls_best_model), num_total_tested_models) < 0.9999) {
|
||||
std::vector<int> inliers_list(models_for_random_test.size());
|
||||
for (int m = 0; m < (int)models_for_random_test.size(); m++)
|
||||
inliers_list[m] = getIndependentInliers(models_for_random_test[m], samples_for_random_test[m],
|
||||
temp_inliers, _quality->getInliers(models_for_random_test[m], temp_inliers));
|
||||
int min_non_rand_inliers;
|
||||
const double lambda = getLambda(inliers_list, 1.644, points_size, sample_size, true, min_non_rand_inliers);
|
||||
const double cdf_lambda = Utils::getPoissonCDF(lambda, non_random_inls_best_model), cdf_N = pow(cdf_lambda, num_total_tested_models);
|
||||
const double cdf_lambda = Utils::getPoissonCDF(lambda, non_random_inls_best_model), cdf_N = std::pow(cdf_lambda, num_total_tested_models);
|
||||
model_conf = cdf_N < 0.9999 ? ModelConfidence ::RANDOM : ModelConfidence ::NON_RANDOM;
|
||||
} else model_conf = ModelConfidence ::NON_RANDOM;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
}
|
||||
|
||||
static int getMaxIterations (int inlier_number, int sample_size, int points_size, double conf) {
|
||||
const double pred_iters = log(1 - conf) / log(1 - pow(static_cast<double>(inlier_number)/points_size, sample_size));
|
||||
const double pred_iters = log(1 - conf) / log(1 - std::pow(static_cast<double>(inlier_number)/points_size, sample_size));
|
||||
if (std::isinf(pred_iters))
|
||||
return INT_MAX;
|
||||
return (int) pred_iters + 1;
|
||||
@@ -322,7 +322,7 @@ public:
|
||||
continue;
|
||||
|
||||
// add 1 to termination length since num_inliers_under_termination_len is updated
|
||||
const double new_max_samples = log_conf/log(1-pow(static_cast<double>(num_inliers_under_termination_len)
|
||||
const double new_max_samples = log_conf/log(1-std::pow(static_cast<double>(num_inliers_under_termination_len)
|
||||
/ (termination_len+1), sample_size));
|
||||
|
||||
if (! std::isinf(new_max_samples) && predicted_iterations > new_max_samples) {
|
||||
|
||||
@@ -194,7 +194,7 @@ TEST_F(UndistortPointsTest, stop_criteria)
|
||||
projectPoints(pt_undist_vec_homogeneous, -rVec,
|
||||
Mat::zeros(3,1,CV_64F), cameraMatrix, distCoeffs, pt_redistorted_vec);
|
||||
|
||||
const double obtainedError = sqrt( pow(pt_distorted.x - pt_redistorted_vec[0].x, 2) + pow(pt_distorted.y - pt_redistorted_vec[0].y, 2) );
|
||||
const double obtainedError = sqrt( std::pow(pt_distorted.x - pt_redistorted_vec[0].x, 2) + std::pow(pt_distorted.y - pt_redistorted_vec[0].y, 2) );
|
||||
|
||||
ASSERT_LE(obtainedError, maxError);
|
||||
}
|
||||
|
||||
@@ -182,8 +182,8 @@ static double getError (TestSolver test_case, int pt_idx, const cv::Mat &pts1, c
|
||||
cv::Mat l2 = model * pt1;
|
||||
cv::Mat l1 = model.t() * pt2;
|
||||
// Sampson error
|
||||
return fabs(pt2.dot(l2)) / sqrt(pow(l1.at<double>(0), 2) + pow(l1.at<double>(1), 2) +
|
||||
pow(l2.at<double>(0), 2) + pow(l2.at<double>(1), 2));
|
||||
return fabs(pt2.dot(l2)) / sqrt(std::pow(l1.at<double>(0), 2) + std::pow(l1.at<double>(1), 2) +
|
||||
std::pow(l2.at<double>(0), 2) + std::pow(l2.at<double>(1), 2));
|
||||
} else
|
||||
if (test_case == TestSolver::PnP) { // PnP, reprojection error
|
||||
cv::Mat img_pt = model * pt2; img_pt /= img_pt.at<double>(2);
|
||||
@@ -233,7 +233,7 @@ TEST(usac_Homography, accuracy) {
|
||||
pts_size, TestSolver ::Homogr, inl_ratio/*inl ratio*/, 0.1 /*noise std*/, gt_inliers);
|
||||
// compute max_iters with standard upper bound rule for RANSAC with 1.5x tolerance
|
||||
const double conf = 0.99, thr = 2., max_iters = 1.3 * log(1 - conf) /
|
||||
log(1 - pow(inl_ratio, 4 /* sample size */));
|
||||
log(1 - std::pow(inl_ratio, 4 /* sample size */));
|
||||
for (auto flag : flags) {
|
||||
cv::Mat mask, H = cv::findHomography(pts1, pts2,flag, thr, mask,
|
||||
int(max_iters), conf);
|
||||
@@ -257,7 +257,7 @@ TEST(usac_Fundamental, accuracy) {
|
||||
for (auto flag : flags) {
|
||||
const int sample_size = flag == USAC_FM_8PTS ? 8 : 7;
|
||||
const double max_iters = 1.25 * log(1 - conf) /
|
||||
log(1 - pow(inl_ratio, sample_size));
|
||||
log(1 - std::pow(inl_ratio, sample_size));
|
||||
cv::Mat mask, F = cv::findFundamentalMat(pts1, pts2,flag, thr, conf,
|
||||
int(max_iters), mask);
|
||||
checkInliersMask(TestSolver::Fundam, inl_size, thr, pts1, pts2, F, mask);
|
||||
@@ -374,7 +374,7 @@ TEST(usac_P3P, accuracy) {
|
||||
int inl_size = generatePoints(rng, img_pts, obj_pts, K1, K2, false /*two calib*/,
|
||||
pts_size, TestSolver ::PnP, inl_ratio, 0.15 /*noise std*/, gt_inliers);
|
||||
const double conf = 0.99, thr = 2., max_iters = 1.3 * log(1 - conf) /
|
||||
log(1 - pow(inl_ratio, 3 /* sample size */));
|
||||
log(1 - std::pow(inl_ratio, 3 /* sample size */));
|
||||
|
||||
for (auto flag : flags) {
|
||||
std::vector<int> inliers;
|
||||
@@ -402,7 +402,7 @@ TEST (usac_Affine2D, accuracy) {
|
||||
int inl_size = generatePoints(rng, pts1, pts2, K1, K2, false /*two calib*/,
|
||||
pts_size, TestSolver ::Affine, inl_ratio, 0.15 /*noise std*/, gt_inliers);
|
||||
const double conf = 0.99, thr = 2., max_iters = 1.3 * log(1 - conf) /
|
||||
log(1 - pow(inl_ratio, 3 /* sample size */));
|
||||
log(1 - std::pow(inl_ratio, 3 /* sample size */));
|
||||
for (auto flag : flags) {
|
||||
cv::Mat mask, A = cv::estimateAffine2D(pts1, pts2, mask, flag, thr, (size_t)max_iters, conf, 0);
|
||||
cv::vconcat(A, cv::Mat(cv::Matx13d(0,0,1)), A);
|
||||
@@ -493,7 +493,7 @@ TEST(usac_solvePnPRansac, regression_21105) {
|
||||
generatePoints(rng, img_pts, obj_pts, K1, K2, false /*two calib*/,
|
||||
pts_size, TestSolver ::PnP, inl_ratio, 0.15 /*noise std*/, gt_inliers);
|
||||
const double conf = 0.99, thr = 2., max_iters = 1.3 * log(1 - conf) /
|
||||
log(1 - pow(inl_ratio, 3 /* sample size */));
|
||||
log(1 - std::pow(inl_ratio, 3 /* sample size */));
|
||||
const int flag = USAC_DEFAULT;
|
||||
std::vector<int> inliers;
|
||||
cv::Matx31d rvec, tvec;
|
||||
|
||||
@@ -580,7 +580,7 @@ CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints,
|
||||
|
||||
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
|
||||
@param patternSize Number of inner corners per a chessboard row and column
|
||||
( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
|
||||
( patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(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:
|
||||
- @ref CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
|
||||
@@ -645,7 +645,7 @@ CV_EXPORTS_W bool checkChessboard(InputArray img, Size size);
|
||||
|
||||
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
|
||||
@param patternSize Number of inner corners per a chessboard row and column
|
||||
( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
|
||||
( patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(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:
|
||||
- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
|
||||
@@ -788,7 +788,7 @@ typedef CirclesGridFinderParameters CirclesGridFinderParameters2;
|
||||
|
||||
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
|
||||
@param patternSize number of circles per row and column
|
||||
( patternSize = Size(points_per_row, points_per_colum) ).
|
||||
( patternSize = Size(points_per_row, points_per_column) ).
|
||||
@param centers output array of detected centers.
|
||||
@param flags various operation flags that can be one of the following values:
|
||||
- @ref CALIB_CB_SYMMETRIC_GRID uses symmetric pattern of circles.
|
||||
|
||||
@@ -670,7 +670,7 @@ bool findChessboardCorners(InputArray image_, Size pattern_size,
|
||||
std::vector<Point2f> out_corners;
|
||||
|
||||
if (is_plain)
|
||||
CV_CheckType(type, depth == CV_8U && cn == 1, "Only 8-bit grayscale images are supported whith CALIB_CB_PLAIN flag enable");
|
||||
CV_CheckType(type, depth == CV_8U && cn == 1, "Only 8-bit grayscale images are supported with CALIB_CB_PLAIN flag enable");
|
||||
|
||||
if (img.channels() != 1)
|
||||
{
|
||||
|
||||
@@ -725,7 +725,7 @@ void FastX::detectImpl(const cv::Mat& _gray_image,
|
||||
// calc images
|
||||
// for each angle step
|
||||
int scale_id = scale-parameters.min_scale;
|
||||
int scale_size = int(pow(2.0,scale+1+super_res));
|
||||
int scale_size = int(std::pow(2,scale+1+super_res));
|
||||
int scale_size2 = int((scale_size/7)*2+1);
|
||||
std::vector<cv::UMat> images;
|
||||
images.resize(2*num);
|
||||
@@ -2242,7 +2242,7 @@ int Chessboard::Board::detectMarkers(cv::InputArray image)
|
||||
cv::bitwise_and(field,mask2,temp);
|
||||
double noise= cv::sum(temp)[0]/noise_size;
|
||||
|
||||
// calc refrence value
|
||||
// calc reference value
|
||||
Cell *cell2 = getCell(y,abs(x-1));
|
||||
src[0] = *cell2->top_left;
|
||||
src[1] = *cell2->top_right;
|
||||
|
||||
@@ -627,7 +627,7 @@ void CV_CameraCalibrationTest::run( int start_from )
|
||||
if( code < 0 )
|
||||
break;
|
||||
|
||||
/* ----- Compare rot matrixs ----- */
|
||||
/* ----- Compare rot matrices ----- */
|
||||
CV_Assert(rotMatrs.size() == (size_t)numImages);
|
||||
CV_Assert(transVects.size() == (size_t)numImages);
|
||||
|
||||
@@ -647,7 +647,7 @@ void CV_CameraCalibrationTest::run( int start_from )
|
||||
if( code < 0 )
|
||||
break;
|
||||
|
||||
/* ----- Compare rot matrixs ----- */
|
||||
/* ----- Compare rot matrices ----- */
|
||||
code = compare(transVects[0].val, goodTransVects[0].val, 3*numImages, 0.1, "translation vectors");
|
||||
if( code < 0 )
|
||||
break;
|
||||
|
||||
@@ -237,6 +237,8 @@ CV_INLINE int cvFloor( double value )
|
||||
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
|
||||
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
|
||||
return (int)__builtin_floor(value);
|
||||
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
|
||||
return (int)vcvtmd_s64_f64(value);
|
||||
#elif defined __loongarch64
|
||||
int i;
|
||||
double tmp;
|
||||
@@ -264,6 +266,8 @@ CV_INLINE int cvCeil( double value )
|
||||
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
|
||||
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
|
||||
return (int)__builtin_ceil(value);
|
||||
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
|
||||
return (int)vcvtpd_s64_f64(value);
|
||||
#elif defined __loongarch64
|
||||
int i;
|
||||
double tmp;
|
||||
@@ -362,6 +366,8 @@ CV_INLINE int cvFloor( float value )
|
||||
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
|
||||
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
|
||||
return (int)__builtin_floorf(value);
|
||||
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
|
||||
return (int)vcvtms_s32_f32(value);
|
||||
#elif defined __loongarch__
|
||||
int i;
|
||||
float tmp;
|
||||
@@ -389,6 +395,8 @@ CV_INLINE int cvCeil( float value )
|
||||
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
|
||||
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
|
||||
return (int)__builtin_ceilf(value);
|
||||
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
|
||||
return (int)vcvtps_s32_f32(value);
|
||||
#elif defined __loongarch__
|
||||
int i;
|
||||
float tmp;
|
||||
|
||||
@@ -68,7 +68,7 @@ CV_EXPORTS void replaceWriteLogMessage(WriteLogMessageFuncType f);
|
||||
|
||||
/**
|
||||
* @brief Replaces the OpenCV writeLogMessageEx function with a user-defined function.
|
||||
* @note The user-defined function must have the same signature as writeLogMessage.
|
||||
* @note The user-defined function must have the same signature as writeLogMessageEx.
|
||||
* @note The user-defined function must accept arguments that can be potentially null.
|
||||
* @note The user-defined function must be thread-safe, as OpenCV logging may be called
|
||||
* from multiple threads.
|
||||
|
||||
@@ -258,7 +258,7 @@ VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcntu)
|
||||
|
||||
// converts between single and double-precision
|
||||
// vec_floate and vec_doubleo are available since Power10 and z14
|
||||
#if defined(__POWER10__) || (defined(__powerpc64__) && defined(__ARCH_PWR10__)
|
||||
#if defined(__POWER10__) || (defined(__powerpc64__) && defined(__ARCH_PWR10__))
|
||||
// Use VSX double<->float conversion instructions (if supported by the architecture)
|
||||
VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, vec_floate)
|
||||
VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, vec_doubleo)
|
||||
|
||||
@@ -1512,16 +1512,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
||||
}
|
||||
else if( d == 0 )
|
||||
{
|
||||
if(R >= 0)
|
||||
{
|
||||
x0 = -2*pow(R, 1./3) - a1/3;
|
||||
x1 = pow(R, 1./3) - a1/3;
|
||||
}
|
||||
else
|
||||
{
|
||||
x0 = 2*pow(-R, 1./3) - a1/3;
|
||||
x1 = -pow(-R, 1./3) - a1/3;
|
||||
}
|
||||
x0 = -2*std::cbrt(R) - a1/3;
|
||||
x1 = std::cbrt(R) - a1/3;
|
||||
x2 = 0;
|
||||
n = x0 == x1 ? 1 : 2;
|
||||
x1 = x0 == x1 ? 0 : x1;
|
||||
@@ -1530,7 +1522,7 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
||||
{
|
||||
double e;
|
||||
d = sqrt(-d);
|
||||
e = pow(d + fabs(R), 1./3);
|
||||
e = std::cbrt(d + fabs(R));
|
||||
if( R > 0 )
|
||||
e = -e;
|
||||
x0 = (e + Q / e) - a1 * (1./3);
|
||||
@@ -1645,15 +1637,14 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
|
||||
if( num_same_root % 2 != 0){
|
||||
Mat cube_coefs(4, 1, CV_64FC1);
|
||||
Mat cube_roots(3, 1, CV_64FC2);
|
||||
cube_coefs.at<double>(3) = -(pow(old_num_re, 3));
|
||||
cube_coefs.at<double>(2) = -(15*pow(old_num_re, 2) + 27*pow(old_num_im, 2));
|
||||
cube_coefs.at<double>(3) = -(std::pow(old_num_re, 3));
|
||||
cube_coefs.at<double>(2) = -(15*std::pow(old_num_re, 2) + 27*std::pow(old_num_im, 2));
|
||||
cube_coefs.at<double>(1) = -48*old_num_re;
|
||||
cube_coefs.at<double>(0) = 64;
|
||||
solveCubic(cube_coefs, cube_roots);
|
||||
|
||||
if(cube_roots.at<double>(0) >= 0) num.re = pow(cube_roots.at<double>(0), 1./3);
|
||||
else num.re = -pow(-cube_roots.at<double>(0), 1./3);
|
||||
num.im = sqrt(pow(num.re, 2) / 3 - old_num_re / (3*num.re));
|
||||
num.re = std::cbrt(cube_roots.at<double>(0));
|
||||
num.im = sqrt(std::pow(num.re, 2) / 3 - old_num_re / (3*num.re));
|
||||
}
|
||||
}
|
||||
roots[i] = p - num;
|
||||
|
||||
@@ -989,7 +989,7 @@ void Mat::release()
|
||||
datastart = dataend = datalimit = data = 0;
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
flags = MAGIC_VAL;
|
||||
flags = (flags & CV_MAT_TYPE_MASK) | MAGIC_VAL;
|
||||
dims = rows = cols = 0;
|
||||
size.clear();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ DECLARE_CV_PAUSE
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __mips__ && __mips_isa_rev >= 2
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("pause" ::: "memory"); } } while (0)
|
||||
# elif defined __APPLE__ && defined __POWERPC__
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("or r27,r27,r27" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __PPC64__
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("or 27,27,27" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __riscv
|
||||
|
||||
@@ -1340,8 +1340,7 @@ void error( const Exception& exc )
|
||||
|
||||
if(breakOnError)
|
||||
{
|
||||
static volatile int* p = 0;
|
||||
*p = 0;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
throw exc;
|
||||
|
||||
@@ -176,14 +176,18 @@ void RotatedRect::points(Point2f pt[]) const
|
||||
float b = (float)cos(_angle)*0.5f;
|
||||
float a = (float)sin(_angle)*0.5f;
|
||||
|
||||
pt[0].x = center.x - a*size.height - b*size.width;
|
||||
pt[0].y = center.y + b*size.height - a*size.width;
|
||||
pt[1].x = center.x + a*size.height - b*size.width;
|
||||
pt[1].y = center.y - b*size.height - a*size.width;
|
||||
pt[2].x = 2*center.x - pt[0].x;
|
||||
pt[2].y = 2*center.y - pt[0].y;
|
||||
pt[3].x = 2*center.x - pt[1].x;
|
||||
pt[3].y = 2*center.y - pt[1].y;
|
||||
const float ah = a*size.height;
|
||||
const float aw = a*size.width;
|
||||
const float bh = b*size.height;
|
||||
const float bw = b*size.width;
|
||||
pt[0].x = center.x - ah - bw;
|
||||
pt[0].y = center.y + bh - aw;
|
||||
pt[1].x = center.x + ah - bw;
|
||||
pt[1].y = center.y - bh - aw;
|
||||
pt[2].x = center.x + ah + bw;
|
||||
pt[2].y = center.y - bh + aw;
|
||||
pt[3].x = center.x - ah + bw;
|
||||
pt[3].y = center.y + bh + aw;
|
||||
}
|
||||
|
||||
void RotatedRect::points(std::vector<Point2f>& pts) const {
|
||||
|
||||
@@ -263,7 +263,7 @@ TEST_P (CountNonZeroND, ndim)
|
||||
data = 0;
|
||||
EXPECT_EQ(0, cv::countNonZero(data));
|
||||
data = Scalar::all(1);
|
||||
int expected = static_cast<int>(pow(static_cast<float>(ONE_SIZE), dims));
|
||||
int expected = static_cast<int>(std::pow(static_cast<float>(ONE_SIZE), dims));
|
||||
EXPECT_EQ(expected, cv::countNonZero(data));
|
||||
}
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ bool Core_EigenTest::check_full(int type)
|
||||
|
||||
for (int i = 0; i < ntests; ++i)
|
||||
{
|
||||
int src_size = (int)(std::pow(2.0, (rng.uniform(0, MAX_DEGREE) + 1.)));
|
||||
int src_size = (int)(std::pow(2, (rng.uniform(0, MAX_DEGREE) + 1.)));
|
||||
|
||||
cv::Mat src(src_size, src_size, type);
|
||||
|
||||
|
||||
@@ -1299,6 +1299,25 @@ TEST(Core_Mat, copyToConvertTo_Empty)
|
||||
ASSERT_EQ(C.type(), CV_32SC2);
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/opencv/opencv/issues/28343
|
||||
// copyTo on empty fixed-type matrices should be a no-op and succeed
|
||||
template <typename T> class Core_Mat_copyTo : public testing::Test {};
|
||||
TYPED_TEST_CASE_P(Core_Mat_copyTo);
|
||||
|
||||
TYPED_TEST_P(Core_Mat_copyTo, EmptyFixedType)
|
||||
{
|
||||
cv::Mat_<TypeParam> a;
|
||||
cv::Mat_<TypeParam> b;
|
||||
EXPECT_NO_THROW(a.copyTo(b));
|
||||
EXPECT_TRUE(b.empty());
|
||||
// Verify type is still consistent after copyTo
|
||||
EXPECT_EQ(b.type(), cv::traits::Type<TypeParam>::value);
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(Core_Mat_copyTo, EmptyFixedType);
|
||||
typedef ::testing::Types<uchar, schar, ushort, short, int, float, double> AllMatDepths;
|
||||
INSTANTIATE_TYPED_TEST_CASE_P(CopyToTest, Core_Mat_copyTo, AllMatDepths);
|
||||
|
||||
TEST(Core_Mat, copyNx1ToVector)
|
||||
{
|
||||
cv::Mat_<uchar> src(5, 1);
|
||||
|
||||
@@ -147,7 +147,7 @@ void Core_PowTest::get_minmax_bounds( int /*i*/, int /*j*/, int type, Scalar& lo
|
||||
if( power > 0 )
|
||||
{
|
||||
double mval = cvtest::getMaxVal(type);
|
||||
double u1 = pow(mval,1./power)*2;
|
||||
double u1 = std::pow(mval,1./power)*2;
|
||||
u = MIN(u,u1);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ void Core_PowTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
for( j = 0; j < ncols; j++ )
|
||||
{
|
||||
double val = ((float*)a_data)[j];
|
||||
val = pow( fabs(val), power );
|
||||
val = std::pow( fabs(val), power );
|
||||
((float*)b_data)[j] = (float)val;
|
||||
}
|
||||
else
|
||||
@@ -341,7 +341,7 @@ void Core_PowTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
for( j = 0; j < ncols; j++ )
|
||||
{
|
||||
double val = ((double*)a_data)[j];
|
||||
val = pow( fabs(val), power );
|
||||
val = std::pow( fabs(val), power );
|
||||
((double*)b_data)[j] = (double)val;
|
||||
}
|
||||
else
|
||||
@@ -1693,7 +1693,7 @@ void Core_SolvePolyTest::run( int )
|
||||
for (int j = 0; j < n; ++j)
|
||||
{
|
||||
s += fabs(r[j].real()) + fabs(r[j].imag());
|
||||
div += sqrt(pow(r[j].real() - ar[j].real(), 2) + pow(r[j].imag() - ar[j].imag(), 2));
|
||||
div += sqrt(std::pow(r[j].real() - ar[j].real(), 2) + std::pow(r[j].imag() - ar[j].imag(), 2));
|
||||
}
|
||||
div /= s;
|
||||
pass = pass && div < err_eps;
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl { namespace cu
|
||||
std::shared_ptr<UniqueHandle> handle;
|
||||
};
|
||||
|
||||
/** @brief GEMM for colummn-major matrices
|
||||
/** @brief GEMM for column-major matrices
|
||||
*
|
||||
* \f$ C = \alpha AB + \beta C \f$
|
||||
*
|
||||
@@ -248,7 +248,7 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl { namespace cu
|
||||
);
|
||||
}
|
||||
|
||||
/** @brief Strided batched GEMM for colummn-major matrices
|
||||
/** @brief Strided batched GEMM for column-major matrices
|
||||
*
|
||||
* \f$ C_i = \alpha A_i B_i + \beta C_i \f$ for a stack of matrices A, B and C indexed by i
|
||||
*
|
||||
@@ -364,7 +364,7 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl { namespace cu
|
||||
);
|
||||
}
|
||||
|
||||
/** @brief Strided batched GEMM for colummn-major matrices
|
||||
/** @brief Strided batched GEMM for column-major matrices
|
||||
*
|
||||
* \f$ C_i = \alpha A_i B_i + \beta C_i \f$ for a stack of matrices A, B and C indexed by i
|
||||
*
|
||||
|
||||
@@ -1008,7 +1008,6 @@ namespace cv {
|
||||
|
||||
if (layer_type == "convolutional" || layer_type == "connected")
|
||||
{
|
||||
size_t weights_size;
|
||||
int filters;
|
||||
bool use_batch_normalize;
|
||||
cv::Mat weightsBlob;
|
||||
@@ -1023,7 +1022,6 @@ namespace cv {
|
||||
CV_Assert(tensor_shape[0] > 0);
|
||||
CV_Assert(tensor_shape[0] % groups == 0);
|
||||
|
||||
weights_size = filters * (tensor_shape[0] / groups) * kernel_size * kernel_size;
|
||||
int sizes_weights[] = { filters, tensor_shape[0] / groups, kernel_size, kernel_size };
|
||||
weightsBlob.create(4, sizes_weights, CV_32F);
|
||||
}
|
||||
@@ -1034,7 +1032,6 @@ namespace cv {
|
||||
|
||||
CV_Assert(filters>0);
|
||||
|
||||
weights_size = total(tensor_shape) * filters;
|
||||
int sizes_weights[] = { filters, total(tensor_shape) };
|
||||
weightsBlob.create(2, sizes_weights, CV_32F);
|
||||
}
|
||||
@@ -1051,7 +1048,7 @@ namespace cv {
|
||||
ifile.read(reinterpret_cast<char *>(meanData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
ifile.read(reinterpret_cast<char *>(stdData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
}
|
||||
ifile.read(reinterpret_cast<char *>(weightsBlob.ptr<float>()), sizeof(float)*weights_size);
|
||||
ifile.read(reinterpret_cast<char *>(weightsBlob.ptr<float>()), sizeof(float)*weightsBlob.total());
|
||||
|
||||
// set conv/connected weights
|
||||
std::vector<cv::Mat> layer_blobs;
|
||||
|
||||
@@ -2354,7 +2354,7 @@ struct PowerFunctor : public BaseFunctor
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = pow(a*x + b, p);
|
||||
dstptr[i] = std::pow(a*x + b, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,9 @@ public:
|
||||
String buildopt = "-DNUM=4" + opts;
|
||||
ocl::Kernel k("mean_fuse4", ocl::dnn::mvn_oclsrc, buildopt + " -DKERNEL_MEAN_FUSE");
|
||||
size_t localsize[] = { LOCAL_SIZE };
|
||||
size_t globalsize[] = { (size_t)s[0] / 4 * localsize[0] };
|
||||
size_t groups = std::max<size_t>(1, s[0] / 4);
|
||||
size_t globalsize[] = { groups * localsize[0] };
|
||||
|
||||
|
||||
int argId = 0;
|
||||
k.set(argId++, ocl::KernelArg::PtrReadOnly(inpMat));
|
||||
@@ -374,7 +376,7 @@ public:
|
||||
const std::vector<MatShape> &outputs) const CV_OVERRIDE
|
||||
{
|
||||
CV_UNUSED(outputs); // suppress unused variable warning
|
||||
long flops = 0;
|
||||
int64 flops = 0;
|
||||
for(int i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
flops += 6*total(inputs[i]) + 3*total(inputs[i], 0, normVariance ? 2 : 1);
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
{
|
||||
// add eps to avoid overflow
|
||||
float absSum = sum(buffer)[0] + epsilon;
|
||||
float norm = pow(absSum, 1.0f / pnorm);
|
||||
float norm = std::pow(absSum, 1.0f / pnorm);
|
||||
multiply(src, 1.0f / norm, dst);
|
||||
}
|
||||
else
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
{
|
||||
// add eps to avoid overflow
|
||||
float absSum = sum(buffer)[0] + epsilon;
|
||||
float norm = pow(absSum, 1.0f / pnorm);
|
||||
float norm = std::pow(absSum, 1.0f / pnorm);
|
||||
multiply(src, 1.0f / norm, dst);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -87,7 +87,7 @@ Range normalizeRange(const Range& input_range, int n)
|
||||
}
|
||||
|
||||
// TODO: support cv::Range with steps and negative steps to get rid of this transformation
|
||||
void tranformForNegSteps(const MatShape& inpShape, std::vector<std::vector<Range> >& sliceRanges, std::vector<std::vector<int> >& sliceSteps)
|
||||
void transformForNegSteps(const MatShape& inpShape, std::vector<std::vector<Range> >& sliceRanges, std::vector<std::vector<int> >& sliceSteps)
|
||||
{
|
||||
// in case of negative steps,
|
||||
// x of shape [5, 10], x[5:0:-1, 10:1:-3] <=> np.flip(x[1:5:1, 2:10:3], aixs=(0, 1))
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
std::vector<std::vector<int> > sliceSteps_ = sliceSteps;
|
||||
std::vector<std::vector<cv::Range> > sliceRanges_ = sliceRanges;
|
||||
if (hasSteps && !neg_step_dims.empty())
|
||||
tranformForNegSteps(inpShape, sliceRanges_, sliceSteps_);
|
||||
transformForNegSteps(inpShape, sliceRanges_, sliceSteps_);
|
||||
|
||||
int axis_rw = axis;
|
||||
std::vector<std::vector<cv::Range> > sliceRanges_rw = finalizeSliceRange(inpShape, axis_rw, sliceRanges_);
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
MatShape inpShape = shape(inputs[0]);
|
||||
|
||||
if (hasSteps && !neg_step_dims.empty())
|
||||
tranformForNegSteps(inpShape, sliceRanges, sliceSteps);
|
||||
transformForNegSteps(inpShape, sliceRanges, sliceSteps);
|
||||
|
||||
finalSliceRanges = finalizeSliceRange(shape(inputs[0]), axis, sliceRanges);
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ public:
|
||||
// Normalize axis
|
||||
int axis_normalized = normalize_axis(axis, input_shape.size());
|
||||
|
||||
// Check if K is in range (0, input_shape[axis])
|
||||
// Check if K is in range (0, input_shape[axis]]
|
||||
CV_CheckGT(K, 0, "TopK: K needs to be a positive integer");
|
||||
CV_CheckLT(K, input_shape[axis_normalized], "TopK: K is out of range");
|
||||
CV_CheckLE(K, input_shape[axis_normalized], "TopK: K is out of range");
|
||||
|
||||
// Assign output shape
|
||||
auto output_shape = input_shape;
|
||||
|
||||
@@ -1327,7 +1327,7 @@ void ONNXImporter::parseSlice(LayerParams& layerParams, const opencv_onnx::NodeP
|
||||
{
|
||||
// dims should be added to the negative axes
|
||||
cur_axe = axes_.getIntValue(i) < 0 ? axes_.getIntValue(i) + dims : axes_.getIntValue(i);
|
||||
CV_CheckGE(cur_axe, 0, "Axes should be grater or equal to '-dims'.");
|
||||
CV_CheckGE(cur_axe, 0, "Axes should be greater or equal to '-dims'.");
|
||||
CV_CheckLT(cur_axe, dims, "Axes should be less than 'dim'.");
|
||||
CV_CheckEQ(flag[cur_axe], false, "Axes shouldn't have duplicated values.");
|
||||
flag[cur_axe] = true;
|
||||
@@ -2193,6 +2193,14 @@ void ONNXImporter::parseSqueeze(LayerParams& layerParams, const opencv_onnx::Nod
|
||||
else
|
||||
CV_Error(Error::StsNotImplemented, cv::format("ONNX/Squeeze: doesn't support non-constant 'axes' input"));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < inpShape.size(); ++i)
|
||||
{
|
||||
if (inpShape[i] == 1)
|
||||
maskedAxes[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
MatShape outShape;
|
||||
for (int i = 0; i < inpShape.size(); ++i)
|
||||
|
||||
@@ -905,7 +905,7 @@ void forwardTimVX(std::vector<Ptr<BackendWrapper> >& outputs, const Ptr<BackendN
|
||||
else
|
||||
return;
|
||||
|
||||
// set ouput
|
||||
// set output
|
||||
Ptr<TimVXBackendWrapper> outWarpper;
|
||||
for (int i = 0; i < outputs.size(); i++)
|
||||
{
|
||||
|
||||
@@ -141,7 +141,7 @@ __kernel void PowForward(const int n, __global const T* in, __global T* out,
|
||||
{
|
||||
int index = get_global_id(0);
|
||||
if (index < n)
|
||||
out[index] = pow(shift + scale * in[index], power);
|
||||
out[index] = std::pow(shift + scale * in[index], power);
|
||||
}
|
||||
|
||||
__kernel void ELUForward(const int n, __global const T* in, __global T* out,
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#define ACTIVATION_RELU_FUNCTION(x, c) ((Dtype)(x) > 0 ? (Dtype)(x) : ((Dtype)(x) * (negative_slope[c])))
|
||||
#define FUSED_ARG __global const KERNEL_ARG_DTYPE* negative_slope,
|
||||
#elif defined(FUSED_CONV_POWER)
|
||||
#define ACTIVATION_RELU_FUNCTION(x, c) pow(x, (Dtype)power)
|
||||
#define ACTIVATION_RELU_FUNCTION(x, c) std::pow(x, (Dtype)power)
|
||||
#define FUSED_ARG KERNEL_ARG_DTYPE power,
|
||||
#elif defined(FUSED_CONV_TANH)
|
||||
#define ACTIVATION_RELU_FUNCTION(x, c) tanh(x)
|
||||
|
||||
@@ -28,7 +28,7 @@ __kernel void LRNComputeOutput(const int nthreads, __global T* in, __global T* s
|
||||
int index = get_global_id(0);
|
||||
int tmp = get_global_size(0);
|
||||
for(index; index < nthreads; index += tmp)
|
||||
out[index] = in[index] * pow(scale[index], negative_beta);
|
||||
out[index] = in[index] * std::pow(scale[index], negative_beta);
|
||||
}
|
||||
|
||||
__kernel void LRNFillScale(const int nthreads, __global T* in, const int num, const int channels, const int height, const int width, const int size, const T alpha_over_size, const T k, __global T* scale) {
|
||||
|
||||
@@ -106,7 +106,7 @@ bool OpMatMul::forward(std::vector<Tensor>& ins, std::vector<Tensor>& outs)
|
||||
}
|
||||
|
||||
desSet->writeTensor(outs[0], 2);
|
||||
desSet->writeTensor(paramTensor, 3); // TODO change the parameter from pushconstance to buffer.
|
||||
desSet->writeTensor(paramTensor, 3); // TODO change the parameter from pushconstant to buffer.
|
||||
|
||||
cmdBuffer->beginRecord();
|
||||
pipeline->bind(cmdBufferReal, desSet->get());
|
||||
|
||||
@@ -496,7 +496,7 @@ size_t DNNTestLayer::getTopMemoryUsageMB()
|
||||
#ifdef _WIN32
|
||||
PROCESS_MEMORY_COUNTERS proc;
|
||||
GetProcessMemoryInfo(GetCurrentProcess(), &proc, sizeof(proc));
|
||||
return proc.PeakWorkingSetSize / pow(1024, 2); // bytes to megabytes
|
||||
return proc.PeakWorkingSetSize / std::pow(1024, 2); // bytes to megabytes
|
||||
#else
|
||||
std::ifstream status("/proc/self/status");
|
||||
std::string line, title;
|
||||
|
||||
@@ -118,6 +118,9 @@ public:
|
||||
net.setInput(inps[i], inputNames[i]);
|
||||
Mat out = net.forward("");
|
||||
|
||||
// BUG: https://github.com/opencv/opencv/issues/28563
|
||||
// EXPECT_EQ(shape(out), shape(ref));
|
||||
|
||||
if (useSoftmax)
|
||||
{
|
||||
LayerParams lp;
|
||||
@@ -1226,6 +1229,7 @@ TEST_P(Test_ONNX_layers, Squeeze)
|
||||
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
|
||||
testONNXModels("squeeze");
|
||||
testONNXModels("squeeze_axes_op13");
|
||||
testONNXModels("squeeze_no_axes");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, ReduceL2)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// software: "Method and apparatus for identifying scale invariant features
|
||||
// in an image and use of same for locating an object in an image," David
|
||||
// G. Lowe, US Patent 6,711,293 (March 23, 2004). Provisional application
|
||||
// filed March 8, 1999. Asignee: The University of British Columbia. For
|
||||
// filed March 8, 1999. Assignee: The University of British Columbia. For
|
||||
// further details, contact David Lowe (lowe@cs.ubc.ca) or the
|
||||
// University-Industry Liaison Office of the University of British
|
||||
// Columbia.
|
||||
@@ -231,10 +231,10 @@ void SIFT_Impl::buildGaussianPyramid( const Mat& base, std::vector<Mat>& pyr, in
|
||||
// precompute Gaussian sigmas using the following formula:
|
||||
// \sigma_{total}^2 = \sigma_{i}^2 + \sigma_{i-1}^2
|
||||
sig[0] = sigma;
|
||||
double k = std::pow( 2., 1. / nOctaveLayers );
|
||||
double k = std::pow( 2, 1. / nOctaveLayers );
|
||||
for( int i = 1; i < nOctaveLayers + 3; i++ )
|
||||
{
|
||||
double sig_prev = std::pow(k, (double)(i-1))*sigma;
|
||||
double sig_prev = (double)std::pow(k, i-1)*sigma;
|
||||
double sig_total = sig_prev*k;
|
||||
sig[i] = std::sqrt(sig_total*sig_total - sig_prev*sig_prev);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// software: "Method and apparatus for identifying scale invariant features
|
||||
// in an image and use of same for locating an object in an image," David
|
||||
// G. Lowe, US Patent 6,711,293 (March 23, 2004). Provisional application
|
||||
// filed March 8, 1999. Asignee: The University of British Columbia. For
|
||||
// filed March 8, 1999. Assignee: The University of British Columbia. For
|
||||
// further details, contact David Lowe (lowe@cs.ubc.ca) or the
|
||||
// University-Industry Liaison Office of the University of British
|
||||
// Columbia.
|
||||
@@ -604,7 +604,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
} else { // val cant be zero here (first abs took care of zero), must be negative
|
||||
} else { // val can't be zero here (first abs took care of zero), must be negative
|
||||
sift_wt vmin = std::min(std::min(std::min(_00,_01),std::min(_02,_10)),std::min(std::min(_12,_20),std::min(_21,_22)));
|
||||
if (val <= vmin)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
This folder contains both KAZE and AKAZE sources.
|
||||
For license details, please refer to the following files:
|
||||
|
||||
- KAZE: LICENSE.KAZE
|
||||
- AKAZE: LICENSE.AKAZE
|
||||
@@ -0,0 +1,26 @@
|
||||
Copyright (c) 2014, Pablo Fernandez Alcantarilla, Jesus Nuevo
|
||||
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.
|
||||
|
||||
* Neither the name of the copyright holders 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 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.
|
||||
@@ -0,0 +1,26 @@
|
||||
Copyright (c) 2012, Pablo Fernández Alcantarilla
|
||||
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.
|
||||
|
||||
* Neither the name of the copyright holders 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 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.
|
||||
@@ -397,7 +397,7 @@ struct MinkowskiDistance
|
||||
diff1 = (ResultType)abs(a[1] - b[1]);
|
||||
diff2 = (ResultType)abs(a[2] - b[2]);
|
||||
diff3 = (ResultType)abs(a[3] - b[3]);
|
||||
result += pow(diff0,order) + pow(diff1,order) + pow(diff2,order) + pow(diff3,order);
|
||||
result += std::pow(diff0,order) + std::pow(diff1,order) + std::pow(diff2,order) + std::pow(diff3,order);
|
||||
a += 4;
|
||||
b += 4;
|
||||
|
||||
@@ -408,7 +408,7 @@ struct MinkowskiDistance
|
||||
/* Process last 0-3 pixels. Not needed for standard vector lengths. */
|
||||
while (a < last) {
|
||||
diff0 = (ResultType)abs(*a++ - *b++);
|
||||
result += pow(diff0,order);
|
||||
result += std::pow(diff0,order);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ struct MinkowskiDistance
|
||||
template <typename U, typename V>
|
||||
inline ResultType accum_dist(const U& a, const V& b, int) const
|
||||
{
|
||||
return pow(static_cast<ResultType>(abs(a-b)),order);
|
||||
return std::pow(static_cast<ResultType>(abs(a-b)),order);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
#include "random.h"
|
||||
#include "saving.h"
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define CV_RESTRICT __restrict__
|
||||
#else
|
||||
#define CV_RESTRICT
|
||||
#endif
|
||||
|
||||
namespace cvflann
|
||||
{
|
||||
@@ -320,9 +325,7 @@ private:
|
||||
int cnt = std::min((int)SAMPLE_MEAN+1, count);
|
||||
for (int j = 0; j < cnt; ++j) {
|
||||
ElementType* v = dataset_[ind[j]];
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
mean_[k] += v[k];
|
||||
}
|
||||
Sum(v, veclen_, mean_);
|
||||
}
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
mean_[k] /= cnt;
|
||||
@@ -331,10 +334,7 @@ private:
|
||||
/* Compute variances (no need to divide by count). */
|
||||
for (int j = 0; j < cnt; ++j) {
|
||||
ElementType* v = dataset_[ind[j]];
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
DistanceType dist = v[k] - mean_[k];
|
||||
var_[k] += dist * dist;
|
||||
}
|
||||
Var(v, mean_, veclen_, var_);
|
||||
}
|
||||
/* Select one of the highest variance indices at random. */
|
||||
cutfeat = selectDivision(var_);
|
||||
@@ -584,6 +584,18 @@ private:
|
||||
RAND_DIM=5
|
||||
};
|
||||
|
||||
void Sum(const ElementType* CV_RESTRICT data, size_t len, DistanceType* CV_RESTRICT mean) {
|
||||
for (size_t k=0; k<len; ++k) {
|
||||
mean[k] += data[k];
|
||||
}
|
||||
}
|
||||
|
||||
void Var(const ElementType* CV_RESTRICT data, const DistanceType* CV_RESTRICT mean, size_t len, DistanceType*CV_RESTRICT var) {
|
||||
for (size_t k=0; k<len; ++k) {
|
||||
DistanceType dist = data[k] - mean[k];
|
||||
var[k] += dist * dist;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of randomized trees that are used
|
||||
|
||||
@@ -519,7 +519,7 @@ fb_fix_screeninfo &FramebufferBackend::getFixInfo()
|
||||
return fixInfo;
|
||||
}
|
||||
|
||||
int FramebufferBackend::getFramebuffrerID()
|
||||
int FramebufferBackend::getFramebufferID()
|
||||
{
|
||||
return fbID;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
|
||||
fb_var_screeninfo &getVarInfo();
|
||||
fb_fix_screeninfo &getFixInfo();
|
||||
int getFramebuffrerID();
|
||||
int getFramebufferID();
|
||||
int getFBWidth();
|
||||
int getFBHeight();
|
||||
int getFBXOffset();
|
||||
|
||||
@@ -233,9 +233,13 @@ bool BmpDecoder::readData( Mat& img )
|
||||
bool color = img.channels() > 1;
|
||||
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;
|
||||
int y, width3 = m_width*nch;
|
||||
|
||||
const int effective_bpp = (m_bpp != 15) ? m_bpp : 16;
|
||||
const RowPitchParams pitch_params = calculateRowPitch(m_width, effective_bpp, 4, "BMP");
|
||||
const int src_pitch = pitch_params.src_pitch;
|
||||
const int width3 = calculateRowSize(m_width, nch, "BMP");
|
||||
int y;
|
||||
|
||||
if( m_offset < 0 || !m_strm.isOpened())
|
||||
return false;
|
||||
@@ -255,7 +259,9 @@ bool BmpDecoder::readData( Mat& img )
|
||||
{
|
||||
CvtPaletteToGray( m_palette, gray_palette, 1 << m_bpp );
|
||||
}
|
||||
_bgr.allocate(m_width*3 + 32);
|
||||
const size_t bgr_size = static_cast<size_t>(m_width) * 3 + 32;
|
||||
CV_CheckLT(bgr_size, MAX_IMAGE_ROW_SIZE, "BMP: bgr buffer size exceeds maximum allowed size");
|
||||
_bgr.allocate(bgr_size);
|
||||
}
|
||||
uchar *src = _src.data(), *bgr = _bgr.data();
|
||||
|
||||
|
||||
@@ -133,10 +133,13 @@ bool SunRasterDecoder::readData( Mat& img )
|
||||
size_t step = img.step;
|
||||
uchar gray_palette[256] = {0};
|
||||
bool result = false;
|
||||
int src_pitch = ((m_width*m_bpp + 7)/8 + 1) & -2;
|
||||
int nch = color ? 3 : 1;
|
||||
int width3 = m_width*nch;
|
||||
int y;
|
||||
|
||||
const RowPitchParams pitch_params = calculateRowPitch(m_width, m_bpp, 2, "SunRaster");
|
||||
const int src_pitch = pitch_params.src_pitch;
|
||||
const size_t bytes_per_row = pitch_params.bytes_per_row;
|
||||
const int width3 = calculateRowSize(m_width, nch, "SunRaster");
|
||||
int y;
|
||||
|
||||
if( m_offset < 0 || !m_strm.isOpened())
|
||||
return false;
|
||||
@@ -169,7 +172,7 @@ bool SunRasterDecoder::readData( Mat& img )
|
||||
}
|
||||
else
|
||||
{
|
||||
uchar* line_end = src + (m_width*m_bpp + 7)/8;
|
||||
uchar* line_end = src + bytes_per_row;
|
||||
uchar* tsrc = src;
|
||||
y = 0;
|
||||
|
||||
|
||||
@@ -51,6 +51,37 @@ int validateToInt(size_t sz)
|
||||
return valueInt;
|
||||
}
|
||||
|
||||
RowPitchParams calculateRowPitch(int width, int bpp, int alignment, const char* format_name)
|
||||
{
|
||||
CV_Assert(width > 0 && bpp > 0 && alignment > 0);
|
||||
CV_Assert((alignment & (alignment - 1)) == 0); // must be power of 2
|
||||
|
||||
const size_t bits_per_row = static_cast<size_t>(width) * static_cast<size_t>(bpp);
|
||||
const size_t bytes_per_row = (bits_per_row + 7) / 8;
|
||||
const size_t aligned_pitch = (bytes_per_row + alignment - 1) & ~static_cast<size_t>(alignment - 1);
|
||||
|
||||
if (aligned_pitch >= MAX_IMAGE_ROW_SIZE)
|
||||
CV_Error(cv::Error::StsOutOfRange,
|
||||
cv::format("%s: src_pitch exceeds maximum allowed size", format_name));
|
||||
|
||||
RowPitchParams result;
|
||||
result.src_pitch = validateToInt(aligned_pitch);
|
||||
result.bytes_per_row = bytes_per_row;
|
||||
return result;
|
||||
}
|
||||
|
||||
int calculateRowSize(int width, int nch, const char* format_name)
|
||||
{
|
||||
CV_Assert(width > 0 && nch > 0);
|
||||
|
||||
const size_t row_size = static_cast<size_t>(width) * static_cast<size_t>(nch);
|
||||
if (row_size >= MAX_IMAGE_ROW_SIZE)
|
||||
CV_Error(cv::Error::StsOutOfRange,
|
||||
cv::format("%s: row size exceeds maximum allowed size", format_name));
|
||||
|
||||
return validateToInt(row_size);
|
||||
}
|
||||
|
||||
#define SCALE 14
|
||||
#define cR (int)(0.299*(1 << SCALE) + 0.5)
|
||||
#define cG (int)(0.587*(1 << SCALE) + 0.5)
|
||||
|
||||
@@ -135,6 +135,16 @@ uchar* FillGrayRow4( uchar* data, uchar* indices, int len, uchar* palette );
|
||||
uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palette );
|
||||
uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette );
|
||||
|
||||
static const size_t MAX_IMAGE_ROW_SIZE = static_cast<size_t>(1) << 28; // 256 MB
|
||||
|
||||
struct RowPitchParams {
|
||||
int src_pitch;
|
||||
size_t bytes_per_row;
|
||||
};
|
||||
|
||||
RowPitchParams calculateRowPitch(int width, int bpp, int alignment, const char* format_name);
|
||||
int calculateRowSize(int width, int nch, const char* format_name);
|
||||
|
||||
CV_INLINE bool isBigEndian( void )
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
||||
@@ -187,7 +187,7 @@ TEST(Imgcodecs_EXR, readWrite_32FC1_PIZ)
|
||||
// Note: YC to GRAYSCALE (IMREAD_GRAYSCALE | IMREAD_ANYDEPTH)
|
||||
// outputs a black image,
|
||||
// as does Y to RGB (IMREAD_COLOR | IMREAD_ANYDEPTH).
|
||||
// This behavoir predates adding EXR alpha support issue
|
||||
// This behavior predates adding EXR alpha support issue
|
||||
// 16115.
|
||||
|
||||
TEST(Imgcodecs_EXR, read_YA_ignore_alpha)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
set(the_description "Image Processing")
|
||||
ocv_add_dispatched_file(accum SSE4_1 AVX AVX2)
|
||||
ocv_add_dispatched_file(bilateral_filter SSE2 AVX2)
|
||||
ocv_add_dispatched_file(bilateral_filter SSE2 AVX2 AVX512_SKX AVX512_ICL)
|
||||
ocv_add_dispatched_file(box_filter SSE2 SSE4_1 AVX2 AVX512_SKX)
|
||||
ocv_add_dispatched_file(filter SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_hsv SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_rgb SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_yuv SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2 AVX512_SKX)
|
||||
ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2 AVX512_SKX AVX512_ICL)
|
||||
ocv_add_dispatched_file(morph SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2 AVX512_ICL)
|
||||
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
|
||||
|
||||
@@ -2401,7 +2401,7 @@ structuring element is used. Kernel can be created using #getStructuringElement
|
||||
@param anchor position of the anchor within the element; default value (-1, -1) means that the
|
||||
anchor is at the element center.
|
||||
@param iterations number of times dilation is applied.
|
||||
@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
|
||||
@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
|
||||
@param borderValue border value in case of a constant border
|
||||
@sa erode, morphologyEx, getStructuringElement
|
||||
*/
|
||||
|
||||
@@ -512,6 +512,9 @@ public:
|
||||
int nlanes_2 = 2 * nlanes;
|
||||
int nlanes_3 = 3 * nlanes;
|
||||
int nlanes_4 = 4 * nlanes;
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
#endif
|
||||
for( i = range.start; i < range.end; i++ )
|
||||
{
|
||||
@@ -523,9 +526,6 @@ public:
|
||||
j = 0;
|
||||
const float* sptr_j = sptr;
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
for(; j <= size.width - nlanes_4; j += nlanes_4, sptr_j += nlanes_4, dptr += nlanes_4)
|
||||
{
|
||||
v_float32 v_wsum0 = vx_setzero_f32();
|
||||
@@ -545,45 +545,37 @@ public:
|
||||
{
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
|
||||
//0th
|
||||
v_float32 val0 = vx_load(ksptr);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), v_not_nan(rval0)), knan0);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
|
||||
//1st
|
||||
v_float32 val1 = vx_load(ksptr + nlanes);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), v_not_nan(rval1)), knan1);
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
|
||||
//2nd
|
||||
v_float32 val2 = vx_load(ksptr + nlanes_2);
|
||||
v_float32 knan2 = v_not_nan(val2);
|
||||
v_float32 alpha2 = v_and(v_and(v_mul(v_absdiff(val2, rval2), sindex), v_not_nan(rval2)), knan2);
|
||||
v_int32 idx2 = v_min(v_trunc(alpha2), vx_setall_s32(kExpNumBins));
|
||||
alpha2 = v_sub(alpha2, v_cvt_f32(idx2));
|
||||
v_float32 w2 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx2), alpha2, v_mul(v_lut(this->expLUT, idx2), v_sub(v_one, alpha2)))), knan2);
|
||||
v_wsum2 = v_add(v_wsum2, w2);
|
||||
v_sum2 = v_muladd(v_and(val2, knan2), w2, v_sum2);
|
||||
|
||||
//3rd
|
||||
v_float32 val3 = vx_load(ksptr + nlanes_3);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 knan2 = v_not_nan(val2);
|
||||
v_float32 knan3 = v_not_nan(val3);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), v_not_nan(rval0)), knan0);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), v_not_nan(rval1)), knan1);
|
||||
v_float32 alpha2 = v_and(v_and(v_mul(v_absdiff(val2, rval2), sindex), v_not_nan(rval2)), knan2);
|
||||
v_float32 alpha3 = v_and(v_and(v_mul(v_absdiff(val3, rval3), sindex), v_not_nan(rval3)), knan3);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx2 = v_min(v_trunc(alpha2), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx3 = v_min(v_trunc(alpha3), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
alpha2 = v_sub(alpha2, v_cvt_f32(idx2));
|
||||
alpha3 = v_sub(alpha3, v_cvt_f32(idx3));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_float32 w2 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx2), alpha2, v_mul(v_lut(this->expLUT, idx2), v_sub(v_one, alpha2)))), knan2);
|
||||
v_float32 w3 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx3), alpha3, v_mul(v_lut(this->expLUT, idx3), v_sub(v_one, alpha3)))), knan3);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_wsum2 = v_add(v_wsum2, w2);
|
||||
v_wsum3 = v_add(v_wsum3, w3);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
v_sum2 = v_muladd(v_and(val2, knan2), w2, v_sum2);
|
||||
v_sum3 = v_muladd(v_and(val3, knan3), w3, v_sum3);
|
||||
}
|
||||
v_store(dptr , v_div(v_add(v_sum0, v_and(rval0, v_not_nan(rval0))), v_add(v_wsum0, v_and(v_one, v_not_nan(rval0)))));
|
||||
@@ -607,24 +599,21 @@ public:
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
|
||||
//0th
|
||||
v_float32 val0 = vx_load(ksptr);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), rval0_not_nan), knan0);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
|
||||
//1st
|
||||
v_float32 val1 = vx_load(ksptr + nlanes);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), rval0_not_nan), knan0);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), rval1_not_nan), knan1);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
}
|
||||
v_store(dptr, v_div(v_add(v_sum0, v_and(rval0, rval0_not_nan)), v_add(v_wsum0, v_and(v_one, rval0_not_nan))));
|
||||
@@ -660,42 +649,61 @@ public:
|
||||
j = 0;
|
||||
const float* sptr_j = sptr;
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
for (; j <= size.width - nlanes; j += nlanes, sptr_j += nlanes_3, dptr += nlanes_3)
|
||||
for (; j <= size.width - nlanes_2; j += nlanes_2, sptr_j += (nlanes_3*2), dptr += (nlanes_3*2))
|
||||
{
|
||||
v_float32 kb, kg, kr, kb1, kg1, kr1;
|
||||
v_float32 rb, rg, rr, rb1, rg1, rr1;
|
||||
const float* rsptr = sptr_j;
|
||||
v_float32 v_wsum = vx_setzero_f32();
|
||||
v_float32 v_sum_b = vx_setzero_f32();
|
||||
v_float32 v_sum_g = vx_setzero_f32();
|
||||
v_float32 v_sum_r = vx_setzero_f32();
|
||||
v_float32 v_wsum1 = vx_setzero_f32();
|
||||
v_float32 v_sum_b1 = vx_setzero_f32();
|
||||
v_float32 v_sum_g1 = vx_setzero_f32();
|
||||
v_float32 v_sum_r1 = vx_setzero_f32();
|
||||
v_load_deinterleave(rsptr, rb, rg, rr);
|
||||
v_load_deinterleave(rsptr + nlanes_3, rb1, rg1, rr1);
|
||||
|
||||
for (k = 0; k < maxk; k++)
|
||||
{
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
|
||||
v_float32 kb, kg, kr, rb, rg, rr;
|
||||
v_load_deinterleave(ksptr, kb, kg, kr);
|
||||
v_load_deinterleave(rsptr, rb, rg, rr);
|
||||
v_load_deinterleave(ksptr + nlanes_3, kb1, kg1, kr1);
|
||||
|
||||
v_float32 knan = v_and(v_and(v_not_nan(kb), v_not_nan(kg)), v_not_nan(kr));
|
||||
v_float32 knan1 = v_and(v_and(v_not_nan(kb1), v_not_nan(kg1)), v_not_nan(kr1));
|
||||
v_float32 alpha = v_and(v_and(v_and(v_and(v_mul(v_add(v_add(v_absdiff(kb, rb), v_absdiff(kg, rg)), v_absdiff(kr, rr)), sindex), v_not_nan(rb)), v_not_nan(rg)), v_not_nan(rr)), knan);
|
||||
v_float32 alpha1 = v_and(v_and(v_and(v_and(v_mul(v_add(v_add(v_absdiff(kb1, rb1), v_absdiff(kg1, rg1)), v_absdiff(kr1, rr1)), sindex), v_not_nan(rb1)), v_not_nan(rg1)), v_not_nan(rr1)), knan1);
|
||||
v_int32 idx = v_min(v_trunc(alpha), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha = v_sub(alpha, v_cvt_f32(idx));
|
||||
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx), alpha, v_mul(v_lut(this->expLUT, idx), v_sub(v_one, alpha)))), knan);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum = v_add(v_wsum, w);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum_b = v_muladd(v_and(kb, knan), w, v_sum_b);
|
||||
v_sum_g = v_muladd(v_and(kg, knan), w, v_sum_g);
|
||||
v_sum_r = v_muladd(v_and(kr, knan), w, v_sum_r);
|
||||
v_sum_b1 = v_muladd(v_and(kb1, knan1), w1, v_sum_b1);
|
||||
v_sum_g1 = v_muladd(v_and(kg1, knan1), w1, v_sum_g1);
|
||||
v_sum_r1 = v_muladd(v_and(kr1, knan1), w1, v_sum_r1);
|
||||
}
|
||||
|
||||
v_float32 b, g, r;
|
||||
v_float32 b1, g1, r1;
|
||||
v_load_deinterleave(sptr_j, b, g, r);
|
||||
v_load_deinterleave(sptr_j + nlanes_3, b1, g1, r1);
|
||||
v_float32 mask = v_and(v_and(v_not_nan(b), v_not_nan(g)), v_not_nan(r));
|
||||
v_float32 mask1 = v_and(v_and(v_not_nan(b1), v_not_nan(g1)), v_not_nan(r1));
|
||||
v_float32 w = v_div(v_one, v_add(v_wsum, v_and(v_one, mask)));
|
||||
v_float32 w1 = v_div(v_one, v_add(v_wsum1, v_and(v_one, mask1)));
|
||||
v_store_interleave(dptr, v_mul(v_add(v_sum_b, v_and(b, mask)), w), v_mul(v_add(v_sum_g, v_and(g, mask)), w), v_mul(v_add(v_sum_r, v_and(r, mask)), w));
|
||||
v_store_interleave(dptr + nlanes_3, v_mul(v_add(v_sum_b1, v_and(b1, mask1)), w1), v_mul(v_add(v_sum_g1, v_and(g1, mask1)), w1), v_mul(v_add(v_sum_r1, v_and(r1, mask1)), w1));
|
||||
}
|
||||
#endif
|
||||
for (; j < size.width; j++, sptr_j += 3)
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace cv {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
@@ -1513,7 +1514,7 @@ void BlockSum(const Mat& _src, Mat& _dst, Size ksize, Point anchor, const Size &
|
||||
borderLeft*sizeof(T), inplace);
|
||||
}
|
||||
else
|
||||
ref = (const T*)(src+(srcY-roi.y)*srcStep);
|
||||
ref = (const T*)(src+(srcY-roi.y)*(ptrdiff_t)srcStep);
|
||||
|
||||
S = ref;
|
||||
R = (T*)alignPtr(border, VEC_ALIGN);
|
||||
|
||||
@@ -598,7 +598,7 @@ static bool ipp_cornerHarris( Mat &src, Mat &dst, int blockSize, int ksize, doub
|
||||
scale *= 2.0;
|
||||
if (depth == CV_8U)
|
||||
scale *= 255.0;
|
||||
scale = std::pow(scale, -4.0);
|
||||
scale = std::pow(scale, -4);
|
||||
|
||||
if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0)
|
||||
{
|
||||
|
||||
@@ -96,7 +96,11 @@ void cv::cornerSubPix( InputArray _image, InputOutputArray _corners,
|
||||
for( int pt_i = 0; pt_i < count; pt_i++ )
|
||||
{
|
||||
Point2f cT = corners[pt_i], cI = cT;
|
||||
CV_Assert( Rect(0, 0, src.cols, src.rows).contains(cT) );
|
||||
if (!Rect(0, 0, src.cols, src.rows).contains(cT))
|
||||
{
|
||||
CV_Error(Error::StsOutOfRange,
|
||||
"cornerSubPix: initial corner is outside the image.");
|
||||
}
|
||||
int iter = 0;
|
||||
double err = 0;
|
||||
|
||||
|
||||
@@ -715,15 +715,30 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
ddepth = sdepth;
|
||||
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
Mat kernel;
|
||||
|
||||
if( ksize == 1 || ksize == 3 )
|
||||
{
|
||||
float K[2][9] =
|
||||
static const double K[2][9] =
|
||||
{
|
||||
{ 0, 1, 0, 1, -4, 1, 0, 1, 0 },
|
||||
{ 2, 0, 2, 0, -8, 0, 2, 0, 2 }
|
||||
};
|
||||
|
||||
Mat kernel(3, 3, CV_32F, K[ksize == 3]);
|
||||
kernel.create(3, 3, ktype);
|
||||
if (ktype == CV_32F)
|
||||
{
|
||||
float* kptr = kernel.ptr<float>();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
kptr[i] = static_cast<float>(K[ksize == 3][i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
double* kptr = kernel.ptr<double>();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
kptr[i] = K[ksize == 3][i];
|
||||
}
|
||||
if( scale != 1 )
|
||||
kernel *= scale;
|
||||
|
||||
@@ -735,20 +750,10 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
|
||||
if( ksize == 1 || ksize == 3 )
|
||||
{
|
||||
float K[2][9] =
|
||||
{
|
||||
{ 0, 1, 0, 1, -4, 1, 0, 1, 0 },
|
||||
{ 2, 0, 2, 0, -8, 0, 2, 0, 2 }
|
||||
};
|
||||
Mat kernel(3, 3, CV_32F, K[ksize == 3]);
|
||||
if( scale != 1 )
|
||||
kernel *= scale;
|
||||
|
||||
filter2D( _src, _dst, ddepth, kernel, Point(-1, -1), delta, borderType );
|
||||
}
|
||||
else
|
||||
{
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
int wdepth = sdepth == CV_8U && ksize <= 5 ? CV_16S : sdepth <= CV_32F ? CV_32F : CV_64F;
|
||||
int wtype = CV_MAKETYPE(wdepth, cn);
|
||||
Mat kd, ks;
|
||||
|
||||
@@ -138,7 +138,7 @@ inline double get_limit(cv::Point2d p, int row, double slope) {
|
||||
inline double log_gamma_windschitl(const double& x)
|
||||
{
|
||||
return 0.918938533204673 + (x-0.5)*log(x) - x
|
||||
+ 0.5*x*log(x*sinh(1/x) + 1/(810.0*pow(x, 6.0)));
|
||||
+ 0.5*x*log(x*sinh(1/x) + 1/(810.0*std::pow(x, 6)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ inline double log_gamma_lanczos(const double& x)
|
||||
for(int n = 0; n < 7; ++n)
|
||||
{
|
||||
a -= log(x + double(n));
|
||||
b += q[n] * pow(x, double(n));
|
||||
b += q[n] * std::pow(x, n);
|
||||
}
|
||||
return a + log(b);
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ double LineSegmentDetectorImpl::nfa(const int& n, const int& k, const double& p)
|
||||
bin_tail += term;
|
||||
if(bin_term < 1)
|
||||
{
|
||||
double err = term * ((1 - pow(mult_term, double(n-i+1))) / (1 - mult_term) - 1);
|
||||
double err = term * ((1 - std::pow(mult_term, double(n-i+1))) / (1 - mult_term) - 1);
|
||||
if(err < tolerance * fabs(-log10(bin_tail) - LOG_NT) * bin_tail) break;
|
||||
}
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
||||
uchar* dst = _dst.ptr();
|
||||
int src_step = (int)_src.step, dst_step = (int)_dst.step;
|
||||
int cn = _src.channels();
|
||||
const uchar* src_max = src + size.height*src_step;
|
||||
const uchar* src_max = src + (size_t)size.height*src_step;
|
||||
CV_Assert(cn > 0 && cn <= 4);
|
||||
|
||||
#define UPDATE_ACC01( pix, cn, op ) \
|
||||
@@ -381,8 +381,8 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
||||
|
||||
if( x % 2 != 0 )
|
||||
{
|
||||
src_bottom = src_top += src_step*(size.height-1);
|
||||
dst_cur += dst_step*(size.height-1);
|
||||
src_bottom = src_top += (size_t)src_step*(size.height-1);
|
||||
dst_cur += (size_t)dst_step*(size.height-1);
|
||||
src_step1 = -src_step1;
|
||||
dst_step1 = -dst_step1;
|
||||
}
|
||||
@@ -663,9 +663,9 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
|
||||
size.width *= cn;
|
||||
for( i = 0; i < size.height; i++, dst += dstep )
|
||||
{
|
||||
const T* row0 = src + std::max(i - 1, 0)*sstep;
|
||||
const T* row1 = src + i*sstep;
|
||||
const T* row2 = src + std::min(i + 1, size.height-1)*sstep;
|
||||
const T* row0 = src + (size_t)std::max(i - 1, 0)*sstep;
|
||||
const T* row1 = src + (size_t)i*sstep;
|
||||
const T* row2 = src + (size_t)std::min(i + 1, size.height-1)*sstep;
|
||||
int limit = cn;
|
||||
|
||||
for(j = 0;; )
|
||||
@@ -750,11 +750,11 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
|
||||
for( i = 0; i < size.height; i++, dst += dstep )
|
||||
{
|
||||
const T* row[5];
|
||||
row[0] = src + std::max(i - 2, 0)*sstep;
|
||||
row[1] = src + std::max(i - 1, 0)*sstep;
|
||||
row[2] = src + i*sstep;
|
||||
row[3] = src + std::min(i + 1, size.height-1)*sstep;
|
||||
row[4] = src + std::min(i + 2, size.height-1)*sstep;
|
||||
row[0] = src + (size_t)std::max(i - 2, 0)*sstep;
|
||||
row[1] = src + (size_t)std::max(i - 1, 0)*sstep;
|
||||
row[2] = src + (size_t)i*sstep;
|
||||
row[3] = src + (size_t)std::min(i + 1, size.height-1)*sstep;
|
||||
row[4] = src + (size_t)std::min(i + 2, size.height-1)*sstep;
|
||||
int limit = cn*2;
|
||||
|
||||
for(j = 0;; )
|
||||
|
||||
@@ -619,7 +619,7 @@ void inline smooth3N121Impl(const ET* src, int cn, ET *dst, int ito, int idst,
|
||||
int v = idst - 1;
|
||||
int len = (width - offset) * cn;
|
||||
int x = offset * cn;
|
||||
int maxRow = min((ito - vOffset),height-2);
|
||||
int maxRow = min((ito - vOffset),height-vOffset);
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
VFT v_8 = vx_setall((WET)8);
|
||||
const int VECSZ = VTraits<VET>::vlanes();
|
||||
@@ -708,11 +708,11 @@ template <typename ET, typename FT, typename WET, typename VFT, typename VET>
|
||||
void inline smooth5N14641Impl(const ET* src, int cn, ET* dst, int ito, int idst, int width, int height, size_t src_stride, size_t dst_stride)
|
||||
{
|
||||
int offset = 2;
|
||||
int vOffset = 3;
|
||||
int vOffset = 4;
|
||||
int v = idst - 2;
|
||||
int len = (width - offset) * cn;
|
||||
int x = offset * cn;
|
||||
int maxRow = min((ito - vOffset),height-4);
|
||||
int maxRow = min((ito - vOffset),height-vOffset);
|
||||
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
VFT v_6 = vx_setall((WET)6);
|
||||
|
||||
@@ -585,6 +585,19 @@ TEST(Imgproc_minAreaRect, reproducer_19769)
|
||||
EXPECT_TRUE(checkMinAreaRect(rr, contour)) << rr.center << " " << rr.size << " " << rr.angle;
|
||||
}
|
||||
|
||||
TEST(Imgproc_minAreaRect, roundtrip_accuracy)
|
||||
{
|
||||
RotatedRect rect(Point2f(12.f, 56.f), Size2f(10.f, 25.f), -45.f);
|
||||
std::vector<Point2f> points;
|
||||
rect.points(points);
|
||||
RotatedRect rect_out = minAreaRect(points);
|
||||
EXPECT_LT(std::abs(rect.center.x - rect_out.center.x), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.center.y - rect_out.center.y), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.size.width - rect_out.size.width), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.size.height - rect_out.size.height), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.angle - rect_out.angle), 1e-5);
|
||||
}
|
||||
|
||||
TEST(Imgproc_minEnclosingTriangle, regression_17585)
|
||||
{
|
||||
const int N = 3;
|
||||
|
||||
@@ -557,9 +557,9 @@ TEST(Drawing, _914)
|
||||
line(img, Point(-5, 20), Point(260, 20), Scalar(0), 2, 4);
|
||||
line(img, Point(10, 0), Point(10, 255), Scalar(0), 2, 4);
|
||||
|
||||
double x0 = 0.0/pow(2.0, -2.0);
|
||||
double x1 = 255.0/pow(2.0, -2.0);
|
||||
double y = 30.5/pow(2.0, -2.0);
|
||||
double x0 = 0.0/std::pow(2, -2);
|
||||
double x1 = 255.0/std::pow(2, -2);
|
||||
double y = 30.5/std::pow(2, -2);
|
||||
|
||||
line(img, Point(int(x0), int(y)), Point(int(x1), int(y)), Scalar(0), 2, 4, 2);
|
||||
|
||||
|
||||
@@ -974,6 +974,19 @@ TEST(Imgproc_MedianBlur, hires_regression_13409)
|
||||
ASSERT_EQ(0.0, cvtest::norm(dst_hires(Rect(516, 516, 1016, 1016)), dst_ref(Rect(4, 4, 1016, 1016)), NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Imgproc_MedianBlur, regression_28385)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_6GB);
|
||||
|
||||
Mat out;
|
||||
// create a matrix larger than 2^31 to check for signed 32 bit integer overflow
|
||||
Mat img(50000, 50000, CV_8U);
|
||||
Mat sub = img(Rect(0, 0, 100, 50000));
|
||||
// this crashes in case of overflow because of out-of-bounds memory access
|
||||
medianBlur(sub, out, 3);
|
||||
ASSERT_EQ(out.size(), Size(100, 50000));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Sobel, s16_regression_13506)
|
||||
{
|
||||
Mat src = (Mat_<short>(8, 16) << 127, 138, 130, 102, 118, 97, 76, 84, 124, 90, 146, 63, 130, 87, 212, 85,
|
||||
|
||||
@@ -258,7 +258,7 @@ struct CV_EXPORTS_W_SIMPLE RefineParameters {
|
||||
*/
|
||||
CV_PROP_RW float errorCorrectionRate;
|
||||
|
||||
/** @brief checkAllOrders consider the four posible corner orders in the rejectedCorners array.
|
||||
/** @brief checkAllOrders consider the four possible corner orders in the rejectedCorners array.
|
||||
*
|
||||
* If it set to false, only the provided corner order is considered (default true).
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ class CV_EXPORTS_W_SIMPLE Dictionary {
|
||||
|
||||
/** @brief Returns Hamming distance of the input bits to the specific id.
|
||||
*
|
||||
* If `allRotations` flag is set, the four posible marker rotations are considered
|
||||
* If `allRotations` flag is set, the four possible marker rotations are considered
|
||||
*/
|
||||
CV_WRAP int getDistanceToId(InputArray bits, int id, bool allRotations = true) const;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
/** @brief Creates an instance of face detector class with given parameters
|
||||
*
|
||||
* @param model the path to the requested model
|
||||
* @param config the path to the config file for compability, which is not requested for ONNX models
|
||||
* @param config the path to the config file for compatibility, which is not requested for ONNX models
|
||||
* @param input_size the size of the input image
|
||||
* @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
|
||||
* @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
/** @brief Creates an instance of this class with given parameters
|
||||
* @param model the path of the onnx model used for face recognition
|
||||
* @param config the path to the config file for compability, which is not requested for ONNX models
|
||||
* @param config the path to the config file for compatibility, which is not requested for ONNX models
|
||||
* @param backend_id the id of backend
|
||||
* @param target_id the id of target device
|
||||
*/
|
||||
|
||||
@@ -103,11 +103,13 @@ public class ArucoTest extends OpenCVTestCase {
|
||||
int[] intCharucoIds = (new MatOfInt(charucoIds)).toArray();
|
||||
Assert.assertArrayEquals(new int[]{0, 1, 2, 3}, intCharucoIds);
|
||||
|
||||
// Note: Expected values adjusted by -0.5px after fixing the systematic offset bug in charuco_detector.cpp
|
||||
// The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
double eps = 0.2;
|
||||
assertArrayEquals(new double[]{cellSize, cellSize}, charucoCorners.get(0,0), eps);
|
||||
assertArrayEquals(new double[]{2*cellSize, cellSize}, charucoCorners.get(0,1), eps);
|
||||
assertArrayEquals(new double[]{cellSize, 2*cellSize}, charucoCorners.get(0,2), eps);
|
||||
assertArrayEquals(new double[]{2*cellSize, 2*cellSize}, charucoCorners.get(0,3), eps);
|
||||
assertArrayEquals(new double[]{cellSize - 0.5, cellSize - 0.5}, charucoCorners.get(0, 0), eps);
|
||||
assertArrayEquals(new double[]{2*cellSize - 0.5, cellSize - 0.5}, charucoCorners.get(0,1), eps);
|
||||
assertArrayEquals(new double[]{cellSize - 0.5, 2*cellSize - 0.5}, charucoCorners.get(0,2), eps);
|
||||
assertArrayEquals(new double[]{2*cellSize - 0.5, 2*cellSize - 0.5}, charucoCorners.get(0,3), eps);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -258,10 +258,12 @@ class aruco_objdetect_test(NewOpenCVTests):
|
||||
|
||||
image = board.generateImage((cell_size*board_size[0], cell_size*board_size[1]))
|
||||
|
||||
# Note: Expected values adjusted by -0.5px after fixing the systematic offset bug in charuco_detector.cpp
|
||||
# The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
list_gold_corners = []
|
||||
for i in range(1, board_size[0]):
|
||||
for j in range(1, board_size[1]):
|
||||
list_gold_corners.append((j*cell_size, i*cell_size))
|
||||
list_gold_corners.append((j*cell_size - 0.5, i*cell_size - 0.5))
|
||||
gold_corners = np.array(list_gold_corners, dtype=np.float32)
|
||||
|
||||
charucoCorners, charucoIds, markerCorners, markerIds = charuco_detector.detectBoard(image)
|
||||
@@ -280,8 +282,10 @@ class aruco_objdetect_test(NewOpenCVTests):
|
||||
|
||||
image = board.generateImage((cell_size*board_size[0], cell_size*board_size[1]))
|
||||
|
||||
list_gold_corners = [(cell_size, cell_size), (2*cell_size, cell_size), (2*cell_size, 2*cell_size),
|
||||
(cell_size, 2*cell_size)]
|
||||
# Note: Expected values adjusted by -0.5px after fixing the systematic offset bug in charuco_detector.cpp
|
||||
# The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
list_gold_corners = [(cell_size - 0.5, cell_size - 0.5), (2*cell_size - 0.5, cell_size - 0.5),
|
||||
(2*cell_size - 0.5, 2*cell_size - 0.5), (cell_size - 0.5, 2*cell_size - 0.5)]
|
||||
gold_corners = np.array(list_gold_corners, dtype=np.float32)
|
||||
|
||||
diamond_corners, diamond_ids, marker_corners, marker_ids = charuco_detector.detectDiamonds(image)
|
||||
@@ -357,7 +361,9 @@ class aruco_objdetect_test(NewOpenCVTests):
|
||||
projectedCharucoCorners, _ = cv.projectPoints(copyChessboardCorners, rvec, tvec, cameraMatrix, distCoeffs)
|
||||
|
||||
if charucoIds is None:
|
||||
self.assertEqual(iteration, 46)
|
||||
# Detection can fail at extreme viewing angles
|
||||
self.assertTrue(abs(yaw) >= 45 or abs(pitch) >= 45,
|
||||
f"Detection failed unexpectedly at yaw={yaw}, pitch={pitch}")
|
||||
continue
|
||||
|
||||
for i in range(len(charucoIds)):
|
||||
|
||||
@@ -518,9 +518,9 @@ void CharucoBoardImpl::generateImage(Size outSize, OutputArray img, int marginSi
|
||||
for(int x = 0; x < size.width; x++) {
|
||||
|
||||
if(legacyPattern && (size.height % 2 == 0)) { // legacy behavior only for even row count patterns
|
||||
if((y + 1) % 2 != x % 2) continue; // white corner, dont do anything
|
||||
if((y + 1) % 2 != x % 2) continue; // white corner, don't do anything
|
||||
} else {
|
||||
if(y % 2 != x % 2) continue; // white corner, dont do anything
|
||||
if(y % 2 != x % 2) continue; // white corner, don't do anything
|
||||
}
|
||||
|
||||
float startX = pixInSquare * float(x);
|
||||
|
||||
@@ -905,7 +905,7 @@ struct ArucoDetector::ArucoDetectorImpl {
|
||||
// only CORNER_REFINE_SUBPIX implement correctly for useAruco3Detection
|
||||
// Todo: update other CORNER_REFINE methods
|
||||
|
||||
// scale to orignal size, this however will lead to inaccurate detections!
|
||||
// scale to original size, this however will lead to inaccurate detections!
|
||||
for (auto &vecPoints : candidates)
|
||||
for (auto &point : vecPoints)
|
||||
point *= 1.f/fxfy;
|
||||
@@ -1399,7 +1399,7 @@ void ArucoDetector::refineDetectedMarkers(InputArray _image, const Board& _board
|
||||
|
||||
// last filter, check if inner code is close enough to the assigned marker code
|
||||
int codeDistance = 0;
|
||||
// if errorCorrectionRate, dont check code
|
||||
// if errorCorrectionRate, don't check code
|
||||
if(refineParams.errorCorrectionRate >= 0) {
|
||||
|
||||
// extract bits
|
||||
|
||||
@@ -117,7 +117,7 @@ struct CharucoDetector::CharucoDetectorImpl {
|
||||
minDist = min(dist, minDist);
|
||||
counter++;
|
||||
}
|
||||
// if this is the first closest marker, dont do anything
|
||||
// if this is the first closest marker, don't do anything
|
||||
if(counter == 0)
|
||||
continue;
|
||||
else {
|
||||
@@ -163,7 +163,7 @@ struct CharucoDetector::CharucoDetectorImpl {
|
||||
const int end = range.end;
|
||||
for (int i = begin; i < end; i++) {
|
||||
vector<Point2f> in;
|
||||
in.push_back(filteredChessboardImgPoints[i] - Point2f(0.5, 0.5)); // adjust sub-pixel coordinates for cornerSubPix
|
||||
in.push_back(filteredChessboardImgPoints[i]);
|
||||
Size winSize = filteredWinSizes[i];
|
||||
if (winSize.height == -1 || winSize.width == -1)
|
||||
winSize = Size(arucoDetector.getDetectorParameters().cornerRefinementWinSize,
|
||||
@@ -172,7 +172,7 @@ struct CharucoDetector::CharucoDetectorImpl {
|
||||
TermCriteria(TermCriteria::MAX_ITER | TermCriteria::EPS,
|
||||
arucoDetector.getDetectorParameters().cornerRefinementMaxIterations,
|
||||
arucoDetector.getDetectorParameters().cornerRefinementMinAccuracy));
|
||||
filteredChessboardImgPoints[i] = in[0] + Point2f(0.5, 0.5);
|
||||
filteredChessboardImgPoints[i] = in[0];
|
||||
}
|
||||
});
|
||||
// parse output
|
||||
|
||||
@@ -1576,7 +1576,7 @@ bool QRCodeDecoderImpl::errorCorrectionBlock(std::vector<uint8_t>& codewords) {
|
||||
uint8_t b = 1; // discrepancy from last L update
|
||||
|
||||
std::vector<uint8_t> C(numSyndromes, 0); // Error locator polynomial
|
||||
std::vector<uint8_t> B(numSyndromes, 0); // A copy of error locator from previos L update
|
||||
std::vector<uint8_t> B(numSyndromes, 0); // A copy of error locator from previous L update
|
||||
C[0] = B[0] = 1;
|
||||
for (size_t i = 0; i < numSyndromes; ++i) {
|
||||
CV_Assert(m + L - 1 < C.size()); // m >= 1 on any iteration
|
||||
@@ -1629,9 +1629,15 @@ bool QRCodeDecoderImpl::errorCorrectionBlock(std::vector<uint8_t>& codewords) {
|
||||
std::vector<uint8_t> errEval;
|
||||
gfPolyMul(C, syndromes, errEval);
|
||||
|
||||
// Precompute all X values for error locations to avoid duplicated computation
|
||||
std::vector<uint8_t> X_values(errLocs.size());
|
||||
for (size_t j = 0; j < errLocs.size(); ++j) {
|
||||
X_values[j] = gfPow(2, static_cast<int>(codewords.size() - 1 - errLocs[j]));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < errLocs.size(); ++i) {
|
||||
uint8_t numenator = 0, denominator = 0;
|
||||
uint8_t X = gfPow(2, static_cast<int>(codewords.size() - 1 - errLocs[i]));
|
||||
uint8_t X = X_values[i];
|
||||
uint8_t inv_X = gfDiv(1, X);
|
||||
|
||||
for (size_t j = 0; j < L; ++j) {
|
||||
@@ -1639,12 +1645,11 @@ bool QRCodeDecoderImpl::errorCorrectionBlock(std::vector<uint8_t>& codewords) {
|
||||
}
|
||||
|
||||
// Compute demoninator as a product of (1-X_i * X_k) for i != k
|
||||
// TODO: optimize, there is a dubplicated compute
|
||||
denominator = 1;
|
||||
for (size_t j = 0; j < errLocs.size(); ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
uint8_t Xj = gfPow(2, static_cast<int>(codewords.size() - 1 - errLocs[j]));
|
||||
uint8_t Xj = X_values[j];
|
||||
denominator = gfMul(denominator, 1 ^ gfMul(inv_X, Xj));
|
||||
}
|
||||
|
||||
|
||||
@@ -205,9 +205,11 @@ TEST(CV_ArucoTutorial, can_find_diamondmarkers)
|
||||
|
||||
const size_t diamondsN = 3;
|
||||
// corners of diamonds with Vec4i indices
|
||||
const float goldDiamondCorners[diamondsN][8] = {{195.6f,150.9f, 213.5f,201.2f, 136.4f,215.3f, 122.4f,163.5f},
|
||||
{501.1f,171.3f, 501.9f,208.5f, 446.2f,199.8f, 447.8f,163.3f},
|
||||
{343.4f,361.2f, 359.7f,328.7f, 400.8f,344.6f, 385.7f,378.4f}};
|
||||
// Note: Values adjusted by -0.5px after fixing the systematic offset bug in charuco_detector.cpp
|
||||
// The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
const float goldDiamondCorners[diamondsN][8] = {{195.1f,150.4f, 213.0f,200.7f, 135.9f,214.8f, 121.9f,163.0f},
|
||||
{500.6f,170.8f, 501.4f,208.0f, 445.7f,199.3f, 447.3f,162.8f},
|
||||
{342.9f,360.7f, 359.2f,328.2f, 400.3f,344.1f, 385.2f,377.9f}};
|
||||
auto comp = [](const Vec4i& a, const Vec4i& b) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (a[i] != b[i]) return a[i] < b[i];
|
||||
|
||||
@@ -602,16 +602,18 @@ TEST(Charuco, testBoardSubpixelCoords)
|
||||
0, 0, 1);
|
||||
|
||||
// set expected_corners values
|
||||
// Note: Values adjusted by -0.5px after fixing the systematic offset bug in charuco_detector.cpp
|
||||
// The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
cv::Mat expected_corners = (cv::Mat_<float>(9,2) <<
|
||||
200, 200,
|
||||
250, 200,
|
||||
300, 200,
|
||||
200, 250,
|
||||
250, 250,
|
||||
300, 250,
|
||||
200, 300,
|
||||
250, 300,
|
||||
300, 300
|
||||
199.5, 199.5,
|
||||
249.5, 199.5,
|
||||
299.5, 199.5,
|
||||
199.5, 249.5,
|
||||
249.5, 249.5,
|
||||
299.5, 249.5,
|
||||
199.5, 299.5,
|
||||
249.5, 299.5,
|
||||
299.5, 299.5
|
||||
);
|
||||
std::vector<int> shape={expected_corners.rows};
|
||||
expected_corners = expected_corners.reshape(2, shape);
|
||||
@@ -904,16 +906,18 @@ TEST(Charuco, DISABLED_testSeveralBoardsWithCustomIds)
|
||||
0, 0.5*res.height, 0.5*res.height,
|
||||
0, 0, 1);
|
||||
|
||||
// Expected corner coordinates adjusted by -0.5px after fixing the systematic offset bug
|
||||
// The fix removes the incorrect +0.5 offset that was added after cornerSubPix
|
||||
Mat expected_corners = (Mat_<float>(9,2) <<
|
||||
200, 200,
|
||||
250, 200,
|
||||
300, 200,
|
||||
200, 250,
|
||||
250, 250,
|
||||
300, 250,
|
||||
200, 300,
|
||||
250, 300,
|
||||
300, 300
|
||||
199.5, 199.5,
|
||||
249.5, 199.5,
|
||||
299.5, 199.5,
|
||||
199.5, 249.5,
|
||||
249.5, 249.5,
|
||||
299.5, 249.5,
|
||||
199.5, 299.5,
|
||||
249.5, 299.5,
|
||||
299.5, 299.5
|
||||
);
|
||||
|
||||
|
||||
@@ -945,11 +949,11 @@ TEST(Charuco, DISABLED_testSeveralBoardsWithCustomIds)
|
||||
// In 4.x detectBoard() returns the charuco corners in a 2D Mat with shape (N_corners, 1)
|
||||
// In 5.x, after PR #23473, detectBoard() returns the charuco corners in a 1D Mat with shape (1, N_corners)
|
||||
ASSERT_EQ(expected_corners.total(), c_corners1.total()*c_corners1.channels());
|
||||
EXPECT_NEAR(0., cvtest::norm(expected_corners.reshape(1, 1), c_corners1.reshape(1, 1), NORM_INF), 3e-1);
|
||||
EXPECT_NEAR(0., cvtest::norm(expected_corners.reshape(1, 1), c_corners1.reshape(1, 1), NORM_INF), 0.1);
|
||||
|
||||
ASSERT_EQ(expected_corners.total(), c_corners2.total()*c_corners2.channels());
|
||||
expected_corners.col(0) += 500;
|
||||
EXPECT_NEAR(0., cvtest::norm(expected_corners.reshape(1, 1), c_corners2.reshape(1, 1), NORM_INF), 3e-1);
|
||||
EXPECT_NEAR(0., cvtest::norm(expected_corners.reshape(1, 1), c_corners2.reshape(1, 1), NORM_INF), 0.1);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -102,7 +102,7 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost)
|
||||
vector <double> temp2(EXPsum.size());
|
||||
vector <double> wei1(polyGrad.size());
|
||||
|
||||
while(sqrt(pow(E-pre_E,2)) > tol)
|
||||
while(std::abs(E-pre_E) > tol)
|
||||
{
|
||||
iterCount +=1;
|
||||
pre_E = E;
|
||||
|
||||
@@ -91,7 +91,7 @@ double Decolor::energyCalcu(const vector <double> &Cg, const vector < vector <do
|
||||
}
|
||||
|
||||
for(size_t i=0;i<polyGrad[0].size();i++)
|
||||
energy[i] = -1.0*log(exp(-1.0*pow(temp[i],2)/sigma) + exp(-1.0*pow(temp1[i],2)/sigma));
|
||||
energy[i] = -1.0*log(exp(-1.0*std::pow(temp[i],2)/sigma) + exp(-1.0*std::pow(temp1[i],2)/sigma));
|
||||
|
||||
double sum = 0.0;
|
||||
for(size_t i=0;i<polyGrad[0].size();i++)
|
||||
@@ -187,7 +187,7 @@ void Decolor::colorGrad(const Mat &img, vector <double> &Cg) const
|
||||
Cg.resize(ImL.size());
|
||||
for(size_t i=0;i<ImL.size();i++)
|
||||
{
|
||||
const double res = sqrt(pow(ImL[i],2) + pow(Ima[i],2) + pow(Imb[i],2))/100;
|
||||
const double res = sqrt(std::pow(ImL[i],2) + std::pow(Ima[i],2) + std::pow(Imb[i],2))/100;
|
||||
Cg[i] = res;
|
||||
}
|
||||
}
|
||||
@@ -288,8 +288,8 @@ void Decolor::grad_system(const Mat &im, vector < vector < double > > &polyGrad,
|
||||
for(int i = 0;i<h;i++)
|
||||
for(int j=0;j<w;j++)
|
||||
curIm.at<float>(i,j)=static_cast<float>(
|
||||
pow(rgb_channel[2].at<float>(i,j),r)*pow(rgb_channel[1].at<float>(i,j),g)*
|
||||
pow(rgb_channel[0].at<float>(i,j),b));
|
||||
std::pow(rgb_channel[2].at<float>(i,j),r)*std::pow(rgb_channel[1].at<float>(i,j),g)*
|
||||
std::pow(rgb_channel[0].at<float>(i,j),b));
|
||||
vector <double> curGrad;
|
||||
gradvector(curIm,curGrad);
|
||||
add_to_vector_poly(polyGrad,curGrad,idx1);
|
||||
@@ -366,8 +366,8 @@ void Decolor::grayImContruct(vector <double> &wei, const Mat &img, Mat &Gray) co
|
||||
for(int i = 0;i<h;i++)
|
||||
for(int j=0;j<w;j++)
|
||||
Gray.at<float>(i,j)=static_cast<float>(Gray.at<float>(i,j) +
|
||||
static_cast<float>(wei[kk])*pow(rgb_channel[2].at<float>(i,j),r)*pow(rgb_channel[1].at<float>(i,j),g)*
|
||||
pow(rgb_channel[0].at<float>(i,j),b));
|
||||
static_cast<float>(wei[kk])*std::pow(rgb_channel[2].at<float>(i,j),r)*std::pow(rgb_channel[1].at<float>(i,j),g)*
|
||||
std::pow(rgb_channel[0].at<float>(i,j),b));
|
||||
|
||||
kk=kk+1;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ void Domain_Filter::compute_Rfilter(Mat &output, Mat &hz, float sigma_h)
|
||||
|
||||
for(int i=0;i<h;i++)
|
||||
for(int j=0;j<w;j++)
|
||||
V.at<float>(i,j) = pow(a,hz.at<float>(i,j));
|
||||
V.at<float>(i,j) = std::pow(a,hz.at<float>(i,j));
|
||||
|
||||
for(int i=0; i<h; i++)
|
||||
{
|
||||
@@ -490,7 +490,7 @@ void Domain_Filter::filter(const Mat &img, Mat &res, float sigma_s = 60, float s
|
||||
|
||||
for(int i=0;i<no_of_iter;i++)
|
||||
{
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * pow(2.0,(no_of_iter - (i+1))) / sqrt(pow(4.0,no_of_iter) -1));
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * std::pow(2,(no_of_iter - (i+1))) / sqrt(std::pow(4,no_of_iter) -1));
|
||||
|
||||
compute_Rfilter(O, horiz, sigma_h);
|
||||
|
||||
@@ -513,7 +513,7 @@ void Domain_Filter::filter(const Mat &img, Mat &res, float sigma_s = 60, float s
|
||||
|
||||
for(int i=0;i<no_of_iter;i++)
|
||||
{
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * pow(2.0,(no_of_iter - (i+1))) / sqrt(pow(4.0,no_of_iter) -1));
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * std::pow(2,(no_of_iter - (i+1))) / sqrt(std::pow(4,no_of_iter) -1));
|
||||
|
||||
radius = (float) sqrt(3.0) * sigma_h;
|
||||
|
||||
@@ -560,7 +560,7 @@ void Domain_Filter::pencil_sketch(const Mat &img, Mat &sketch, Mat &color_res, f
|
||||
|
||||
for(int i=0;i<no_of_iter;i++)
|
||||
{
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * pow(2.0,(no_of_iter - (i+1))) / sqrt(pow(4.0,no_of_iter) -1));
|
||||
sigma_h = (float) (sigma_s * sqrt(3.0) * std::pow(2,(no_of_iter - (i+1))) / sqrt(std::pow(4,no_of_iter) -1));
|
||||
|
||||
radius = (float) sqrt(3.0) * sigma_h;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user