Commit Graph

398 Commits

Author SHA1 Message Date
Alexander Smorkalov
fd576d9e8e Added PNG instance of image for fisheye::undistort test as JPG is decoded differently with different libjpeg versions. 2024-03-28 12:02:58 +03:00
Maxim Smolskiy
e3ff6ce0cc
Merge pull request #25182 from MaximSmolskiy:increase-decomposeProjectionMatrix-precision-for-small-scales
Increase decomposeProjectionMatrix precision for small scales #25182 

### Pull Request Readiness Checklist

Fix #23733

It is checked before that `|s| > DBL_EPSILON` (if not, then `s` will be equal to `0`, but `c` will be equal to `1`, then `z` will be equal to `1` and there will be no any problems with small values), so `sqrt(c^2 + s^2) >= |s| > DBL_EPSILON` and thus small values are already taken into account before and there is no need to add `DBL_EPSILON` to `c^2 + s^2` (and I think adding `DBL_EPSILON^2` instead of `DBL_EPSILON` would be more correct).

I ran `Python` script from issue.

`NumPy` and `SciPy` results
```
*Numpy*
P (case 1): 
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]]
Numpy, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
Numpy scaled 1e-6, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
P (case 2): 
[[52. -7.  4. 12.]
 [-6. 49. 12.  8.]
 [ 4. 17.  1.  0.]]
Numpy, R.T @ R - I: 
[[-8.88178420e-16 -3.86302608e-16 -2.52050796e-17]
 [-3.86302608e-16 -5.55111512e-16  7.11675423e-18]
 [-2.52050796e-17  7.11675423e-18 -5.55111512e-16]]
Numpy scaled 1e-6, R.T @ R - I: 
[[ 2.22044605e-16 -2.00683644e-16 -1.90063998e-17]
 [-2.00683644e-16  0.00000000e+00  1.16926308e-17]
 [-1.90063998e-17  1.16926308e-17  2.22044605e-16]]

*Scipy*
P (case 1): 
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]]
Scipy, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
Scipy scaled 1e-6, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
P (case 2): 
[[52. -7.  4. 12.]
 [-6. 49. 12.  8.]
 [ 4. 17.  1.  0.]]
Scipy, R.T @ R - I: 
[[-1.11022302e-16 -8.74062812e-18 -1.26178867e-17]
 [-8.74062812e-18 -1.11022302e-16  2.07820373e-17]
 [-1.26178867e-17  2.07820373e-17 -1.11022302e-16]]
Scipy scaled 1e-6, R.T @ R - I: 
[[0.00000000e+00 4.04691435e-17 1.12452918e-16]
 [4.04691435e-17 4.44089210e-16 3.74164141e-16]
 [1.12452918e-16 3.74164141e-16 4.44089210e-16]]

*Numpy*
Numpy, P' - P:
 [[ 1.35525272e-20 -9.31736242e-21  8.47032947e-22  3.38813179e-21]
 [-3.38813179e-21  6.77626358e-21  1.69406589e-21  0.00000000e+00]
 [-1.69406589e-21  0.00000000e+00  0.00000000e+00  4.85524279e-22]]

*Scipy*
Scipy, P' - P:
 [[0.00000000e+00 8.47032947e-22 3.38813179e-21 3.38813179e-21]
 [3.38813179e-21 1.35525272e-20 1.52465931e-20 1.52465931e-20]
 [8.47032947e-22 3.38813179e-21 2.54109884e-21 3.39866995e-21]]
```

`OpenCV` results before
```
*OpenCV*
P (case 1): 
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]]
OpenCV, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
OpenCV scaled 1e-6, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
P (case 2): 
[[52. -7.  4. 12.]
 [-6. 49. 12.  8.]
 [ 4. 17.  1.  0.]]
OpenCV, R.T @ R - I: 
[[ 2.22044605e-16 -9.12253504e-17 -2.20527203e-19]
 [-9.12253504e-17  0.00000000e+00 -9.12405093e-18]
 [-2.20527203e-19 -9.12405093e-18  2.22044605e-16]]
OpenCV scaled 1e-6, R.T @ R - I: 
[[-1.28197013e-06  1.30450769e-07  7.67357467e-09]
 [ 1.30450769e-07 -1.52141637e-06 -9.92455574e-09]
 [ 7.67357467e-09 -9.92455574e-09 -1.35328272e-06]]

*OpenCV*
OpenCV, P' - P:
 [[-6.75449076e-11  1.73936564e-11 -4.94463312e-12 -1.61106020e-11]
 [ 1.41759913e-11 -7.54512016e-11 -1.67717374e-11 -9.74644390e-12]
 [-2.90254385e-12 -2.53521998e-11 -1.49130587e-12  4.00724440e-13]]
```

`OpenCV` results after
```
*OpenCV*
P (case 1): 
[[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]]
OpenCV, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
OpenCV scaled 1e-6, R.T @ R - I: 
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
P (case 2): 
[[52. -7.  4. 12.]
 [-6. 49. 12.  8.]
 [ 4. 17.  1.  0.]]
OpenCV, R.T @ R - I: 
[[ 2.22044605e-16 -9.12253504e-17 -2.20527203e-19]
 [-9.12253504e-17  0.00000000e+00 -9.12405093e-18]
 [-2.20527203e-19 -9.12405093e-18  2.22044605e-16]]
OpenCV scaled 1e-6, R.T @ R - I: 
[[ 0.00000000e+00  4.36198333e-17 -2.66855078e-17]
 [ 4.36198333e-17  2.22044605e-16  3.17216400e-17]
 [-2.66855078e-17  3.17216400e-17 -2.22044605e-16]]

*OpenCV*
OpenCV, P' - P:
 [[ 6.77626358e-21  0.00000000e+00 -8.47032947e-22  1.69406589e-21]
 [-1.69406589e-21  6.77626358e-21  0.00000000e+00  3.38813179e-21]
 [ 8.47032947e-22  3.38813179e-21  2.11758237e-22  1.45657284e-21]]
```

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-03-27 12:43:56 +03:00
Alexander Smorkalov
4dc461717f
Merge pull request #25258 from AleksandrPanov:fix_rotated_symmetric_grid
Fix detect rotated SYMMETRIC_GRID
2024-03-26 17:23:05 +03:00
Alex
eaa88e7bc7 fix detect rotated grid, added test 2024-03-25 14:07:03 +03:00
Alexander Smorkalov
daa8f7dfc6 Partially back-port #25075 to 4.x 2024-03-05 12:15:39 +03:00
Adrian Kretz
e0b489e917
Merge pull request #25050 from akretz:fix_issue_24330
Handle degenerate cases in RQDecomp3x3 #25050

The point of the Givens rotations here is to iteratively set the lower left matrix entries to zero. If an element is zero already, we don't need to do anything. This resolves #24330.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-02-27 08:10:21 +03:00
Maxim Smolskiy
853f7ff904
Merge pull request #25090 from MaximSmolskiy:compensate-edge-length-in-ChessBoardDetector-generateQuads-attempt-2
Compensate edge length in ChessBoardDetector::generateQuads (attempt 2) #25090

### Pull Request Readiness Checklist

New attempt for #24833, which was reverted as #25036.

Locally I fixed `Calib3d_StereoCalibrate_CPP.regression` test by corners refinement using `cornerSubPix` function

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-02-26 12:12:53 +03:00
Alexander Smorkalov
bd73b7bcf5
Merge pull request #25028 from asmorkalov:as/fisheye_solvepnp
solvePnP implementation for Fisheye camera model #25028

Credits to Linfei Pan
Extracted from https://github.com/opencv/opencv/pull/24052

**Warning:** The patch changes Obj-C generator behaviour and adds "fisheye_" prefix for all ObjC functions from namespace.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake

Co-authored-by: lpanaf <linpan@student.ethz.ch>
Co-authored-by: Vadim Levin <vadim.levin@xperience.ai>
2024-02-16 17:54:40 +03:00
lpanaf
b87058f7ac Changed initial estimation for F in fisheye calibration. 2024-02-15 16:22:30 +03:00
thewoz
e64c5dc4c6
Merge pull request #24546 from thewoz:checkerboard
Check Checkerboard Corners #24546

What I did was get you to pull out of findChessboardCorners cornres the whole part that "checks" and sorts the corners of the checkerboard if present.
The main reason for this is that findChessboardCorners is often very slow to find the corners and this depends in that the size the contrast etc of the checkerboards can be very different from each other and writing a function that works on all kinds of images is complicated. 
So I find it very useful to have the ability to write your own code to process the image and then have a function that controls or orders the corners.


### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2023-12-20 18:01:39 +03:00
MaximSmolskiy
9517fcf80d Fix time measurement in test Calib3d_ChessboardDetector.timing 2023-11-27 23:44:24 +03:00
Yuriy Chernyshov
8a415c881a Add missing std namespace qualifiers 2023-09-06 13:46:39 +03:00
alexander-varjo
114c23e411
Merge pull request #23607 from alexander-varjo:alexander-varjo-patch-1
Fix crash in ap3p #23607

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2023-09-04 17:49:45 +03:00
Vincent Rabaud
15815fb54d Fix stereoRectify image boundaries.
This should hav ebeen fixed with https://github.com/opencv/opencv/issues/23304
2023-07-27 17:47:26 +03:00
Maksim Shabunin
09944a83d9 build: w/a compiler warnings for GCC 11-12 and Clang 13, reduce build output 2023-07-10 11:27:59 +03:00
Maksym Ivashechkin
44881592c3
Merge pull request #23078 from ivashmak:update_vsac
Update USAC #23078

### Pull Request Readiness Checklist

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2023-06-16 10:59:13 +03:00
Alexander Smorkalov
e4a29d93fe Merge remote-tracking branch 'origin/3.4' into merge-3.4 2023-04-21 10:55:04 +03:00
Bhavit Patel
7ea6b356c7
Merge pull request #23305 from bhavitp:fix/calib3d/undistortion_grid
Resolves https://github.com/opencv/opencv/issues/23304

Fixes the incorrect pixel grid
Switches type to double to avoid precision loss as all callers use doubles

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [X] I agree to contribute to the project under Apache 2 License.
- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [X] The PR is proposed to the proper branch
- [X] There is a reference to the original bug report and related work
- [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [X] The feature is well documented and sample code can be built with the project CMake
2023-03-10 09:50:36 +03:00
Alexander Smorkalov
3d635cb4a7 Warning supression fix for XCode 13.1 and newer. Backport #23203 2023-02-06 11:12:05 +03:00
Alexander Alekhin
d3ae175bca Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2023-01-28 10:01:23 +00:00
Rostislav Vasilikhin
deaf632881
Merge pull request #23179 from savuor:port34_stddev_calib_fisheye
Backport to 3.4 of the fisheye calibration uncertainty fix

* uncertainties fix

* trailing whitespace

* comment added
2023-01-28 09:56:13 +00:00
Alexander Alekhin
18cbfa4a4f Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2023-01-23 00:11:12 +00:00
Alexander Smorkalov
3085fc6345
Merge pull request #23073 from savuor:fix_graphcut_used_edges_dense
USAC fix: GraphCut fails to allocate big dense matrices
2023-01-20 14:55:40 +03:00
Alexander Alekhin
69020666fe test: reproducible results, enabled 2-channel tests, increased some thresholds 2023-01-19 15:39:33 +03:00
Funatomi Takuya
dbdd357b0a Extend USAC coverage.
Add `estimateSE2(...)`, `estimateSE3(...)`, `estimateSIM2(...)`, `estimateSIM3(...)` for estimating an geometric transformation with rotation and translation (with scaling for SIM) using USAC: as alternative for `estimateAffinePartial2D` and `estimateAffine3D`.

Modified test module.

Remove unused variables.

Remove initializer of unused variable.

Add interfaces to accept UsacParams() and corresponding test codes.

Revise test code.

PartialNd removed

Umeyama rewritten for code quality & speed

comments & minors

rise number of points

fix, and +30% faster!

only one number should be that big

remove USAC code, leave fix only

big number
2023-01-18 02:12:57 +01:00
Maksim Shabunin
c1e5c16ff3 Backport C-API cleanup (imgproc) from 5.x 2023-01-16 23:29:50 +03:00
Christoph Rackwitz
a64b51dd94
Merge pull request #23108 from crackwitz:issue-23107
Usage of imread(): magic number 0, unchecked result

* docs: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()

* samples, apps: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()

* tests: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()

* doc/py_tutorials: check imread() result
2023-01-09 09:55:31 +00:00
Alexander Alekhin
38f7cd7173 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-12-27 08:58:28 +00:00
Rostislav Vasilikhin
93aa94e71e backported changes
no lambda

whitespace

fixing build Java tests
2022-12-27 00:54:39 +01:00
Sergei Shutov
3cfe737581 Fix hardcoded maxIters 2022-12-21 09:51:59 +03:00
Alexander Alekhin
be326ff752 build: fix/eliminate MSVC warnings 2022-12-10 12:19:31 +00:00
Stefan Spiss
66cbb7b911 Extended tests for stereoCalibrate function of fisheye camera model. 2022-09-15 13:28:41 +02:00
Stefan Spiss
9ca3a3139a Extended tests for stereoCalibrate function of pinhole camera model. 2022-09-15 13:28:41 +02:00
Alexander Alekhin
d6151eae23 Merge pull request #22019 from victor1234:calib3d-fix-cameracalibration-test 2022-05-30 18:27:14 +00:00
Alexander Alekhin
434c96e625 build: eliminate warnings 2022-05-24 23:34:11 +00:00
Kataev Victor
50bf0e10f5 Fix cameracalibration test
* Remove transpose for rvec after calibration
* Change compare threshold from 110% to 10% for perViewErrors
* Add transpose to goodRotMatrs load
2022-05-23 14:07:34 +03:00
Kumataro
602caa9cd6
Merge pull request #21937 from Kumataro:4.x-fix-21911
* Fix warnings for clang15

* Fix warnings: Remove unnecessary code

* Fix warnings: Remove unnecessary code
2022-05-13 17:32:05 +00:00
Victor
2b67bc448d
Merge pull request #21931 from victor1234:calib3d-add-undistortImagePoints
Add undistortImagePoints function

* Add undistortImagePoints function
undistortPoints has unclear interface and additional functionality. New function computes only undistorted image points position

* Add undistortImagePoints test

* Add TermCriteria

* Fix layout
2022-05-12 08:56:58 +00:00
Kataev Victor
6d0f1275c2 Add use of R and P parameters to cv::undistortPoints test 2022-04-28 21:47:53 +03:00
Victor
5cc154147f
Merge pull request #21841 from victor1234:calib3d-undistortPoints-tests
Add distort/undistort test for fisheye::undistortPoints()

* Add distort/undistort test for fisheye::undistortPoints()

Lack of test has allowed error described in 19138 to be unnoticed.
In addition to random points, four corners and principal center
added to point set

* Add random distortion coefficients set

* Move undistortPoints test to google test, refactor

* Add fisheye::undistortPoints() perf test

* Add negative distortion coefficients to undistortPoints test, increase value

* Move to theRNG()

* Change test check from cvtest::norm(L2) to EXPECT_MAT_NEAR()

* Layout fix

* Add points number parameters, comments
2022-04-19 18:07:34 +00:00
Polina Smolnikova
456137fa24
Merge pull request #21166 from rayonnant14:issue_21105
Fix intrinsics processing in case USAC parameters

* fixed USAC intrinsics processing

* change mat to matx33d, added test
2021-12-13 17:12:49 +00:00
Alexander Alekhin
8b4fa2605e Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-12-03 12:32:49 +00:00
yuki takehara
a6277370ca
Merge pull request #21107 from take1014:remove_assert_21038
resolves #21038

* remove C assert

* revert C header

* fix several points in review

* fix test_ds.cpp
2021-11-27 18:34:52 +00:00
thezane
9e835e8edb
Merge pull request #20636 from thezane:recoverPoseFromDifferentCameras
Recover pose from different cameras (version 2)

* add recoverPose for two different cameras

* Address review comments from original PR

* Address new review comments

* Rename private api

Co-authored-by: tompollok <tom.pollok@gmail.com>
Co-authored-by: Zane <zane.huang@mail.utoronto.ca>
2021-09-25 17:42:12 +00:00
Ian Maquignaz
464441d8c3 Added new unit test for initInverseRectificationMap()
Function is validated. Included an update to DISABLED_Calib3d_InitInverseRectificationMap.

Includes updates per input from @alalek and unit test regression # to reflect PR #
2021-06-17 12:48:16 -04:00
Ian Maquignaz
2db243b8ed
Merge pull request #20247 from IanMaquignaz:inverseRectification_update
Update to initInverseRectificationMap()

* update to initInverseRectificationMap() documentation

* Restructured Calib3d_InitInverseRectificationMap unit test per feedback from alalek

* whitespace
2021-06-09 13:27:43 +00:00
Ian Maquignaz
b05631432b Added declaration, definition and unit test for initInverseRectificationMap()
Fixed trailing whitespace

Update to initInverseRectificationMap documentation for clarity

Added test case for initInverseRectificationMap()
Updated documentation.

Fixed whitespace error in docs

Small update to test function
Now passes success_error_level

final update to inverseRectification documentation
2021-06-07 16:01:11 -04:00
Vadim Pisarevsky
cc712a165d Merge pull request #19689 from andy-held:umeyama 2021-05-25 13:18:21 +00:00
Maksym Ivashechkin
527d86a93d
Merge pull request #20012 from ivashmak:bugfix_solvepnp
* fix inliers in solvePnPRansac

* fix inliers in test_usac

* fix inliers in test_usac
2021-05-19 12:09:46 +03:00
Andreas Franek
4ed91ce7ed add estimateAffine3D overload that implements Umeyama's algorithm 2021-04-28 11:33:48 +02:00