Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Dec 24, 2022
2 parents 5247237 + 139bd30 commit bc8c912
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
15 changes: 11 additions & 4 deletions modules/calib3d/src/solvepnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ class PnPRansacCallback CV_FINAL : public PointSetRegistrator::Callback
int runKernel( InputArray _m1, InputArray _m2, OutputArray _model ) const CV_OVERRIDE
{
Mat opoints = _m1.getMat(), ipoints = _m2.getMat();

Mat iter_rvec = rvec.clone();
Mat iter_tvec = tvec.clone();
bool correspondence = solvePnP( _m1, _m2, cameraMatrix, distCoeffs,
rvec, tvec, useExtrinsicGuess, flags );
iter_rvec, iter_tvec, useExtrinsicGuess, flags );

Mat _local_model;
hconcat(rvec, tvec, _local_model);
hconcat(iter_rvec, iter_tvec, _local_model);
_local_model.copyTo(_model);

return correspondence;
Expand Down Expand Up @@ -336,7 +337,13 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
ipoints_inliers.resize(npoints1);
try
{
result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
if (flags == SOLVEPNP_ITERATIVE && !useExtrinsicGuess)
{
rvec = _local_model.col(0).clone();
tvec = _local_model.col(1).clone();
useExtrinsicGuess = true;
}
result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
distCoeffs, rvec, tvec, useExtrinsicGuess,
(flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
}
Expand Down
5 changes: 2 additions & 3 deletions modules/core/src/parallel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ DECLARE_CV_PAUSE
static inline void cv_non_sse_mm_pause() { __asm__ __volatile__ ("rep; nop"); }
# define _mm_pause cv_non_sse_mm_pause
# endif
// 5 * v is meants for backward compatibility: with pre-Skylake CPUs, _mm_pause took 4 or 5 cycles.
// With post-Skylake CPUs, _mm_pause takes 140 cycles.
# define CV_PAUSE(v) do { const uint64_t __delay = 5 * v; uint64_t __init = __rdtsc(); do { _mm_pause(); } while ((__rdtsc() - __init) < __delay); } while (0)
// With Skylake CPUs and above, _mm_pause takes 140 cycles so no need for a loop.
# define CV_PAUSE(v) do { (void)v; _mm_pause(); } while (0)
# elif defined __GNUC__ && defined __aarch64__
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
# elif defined __GNUC__ && defined __arm__
Expand Down
6 changes: 6 additions & 0 deletions modules/imgproc/src/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ inline int dstChannels(int code)
case COLOR_YUV2BGR_YV12: case COLOR_YUV2RGB_YV12: case COLOR_YUV2BGR_IYUV: case COLOR_YUV2RGB_IYUV:
case COLOR_YUV2RGB_UYVY: case COLOR_YUV2BGR_UYVY: case COLOR_YUV2RGB_YVYU: case COLOR_YUV2BGR_YVYU:
case COLOR_YUV2RGB_YUY2: case COLOR_YUV2BGR_YUY2:
case COLOR_Lab2BGR: case COLOR_Lab2RGB: case COLOR_BGR2Lab: case COLOR_RGB2Lab:
case COLOR_Lab2LBGR: case COLOR_Lab2LRGB:
case COLOR_Luv2BGR: case COLOR_Luv2RGB: case COLOR_BGR2Luv: case COLOR_RGB2Luv:
case COLOR_Luv2LBGR: case COLOR_Luv2LRGB:
case COLOR_YCrCb2BGR: case COLOR_YCrCb2RGB: case COLOR_BGR2YCrCb: case COLOR_RGB2YCrCb:
case COLOR_XYZ2BGR: case COLOR_XYZ2RGB: case COLOR_BGR2XYZ: case COLOR_RGB2XYZ:

return 3;

Expand Down

0 comments on commit bc8c912

Please sign in to comment.