1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2026-02-19 17:10:14 +03:00
120 changed files with 650 additions and 465 deletions
+61 -20
View File
@@ -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(),
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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
*/
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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) {
+1 -1
View File
@@ -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);
}
+7 -7
View File
@@ -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;
+3 -3
View File
@@ -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.
+1 -1
View File
@@ -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)
{
+2 -2
View File
@@ -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)
+7 -16
View File
@@ -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;
+1 -1
View File
@@ -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();
}
+2
View File
@@ -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
+1 -2
View File
@@ -1340,8 +1340,7 @@ void error( const Exception& exc )
if(breakOnError)
{
static volatile int* p = 0;
*p = 0;
std::terminate();
}
throw exc;
+12 -8
View File
@@ -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 {
+1 -1
View File
@@ -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));
}
+1 -1
View File
@@ -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);
+19
View File
@@ -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);
+4 -4
View File
@@ -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;
+3 -3
View File
@@ -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
*
+1 -4
View File
@@ -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);
}
}
}
+4 -2
View File
@@ -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
+3 -3
View File
@@ -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);
+2 -2
View File
@@ -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;
+9 -1
View File
@@ -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)
+1 -1
View File
@@ -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++)
{
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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());
+1 -1
View File
@@ -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;
+4
View File
@@ -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)
+3 -3
View File
@@ -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);
}
+2 -2
View File
@@ -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)
{
+5
View File
@@ -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
+26
View File
@@ -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.
+26
View File
@@ -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.
+3 -3
View File
@@ -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
+1 -1
View File
@@ -519,7 +519,7 @@ fb_fix_screeninfo &FramebufferBackend::getFixInfo()
return fixInfo;
}
int FramebufferBackend::getFramebuffrerID()
int FramebufferBackend::getFramebufferID()
{
return fbID;
}
+1 -1
View File
@@ -101,7 +101,7 @@ public:
fb_var_screeninfo &getVarInfo();
fb_fix_screeninfo &getFixInfo();
int getFramebuffrerID();
int getFramebufferID();
int getFBWidth();
int getFBHeight();
int getFBXOffset();
+9 -3
View File
@@ -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();
+7 -4
View File
@@ -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;
+31
View File
@@ -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)
+10
View File
@@ -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
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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
*/
+56 -48
View File
@@ -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)
+2 -1
View File
@@ -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);
+1 -1
View File
@@ -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)
{
+5 -1
View File
@@ -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;
+17 -12
View File
@@ -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;
+3 -3
View File
@@ -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;
}
+11 -11
View File
@@ -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;; )
+3 -3
View File
@@ -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);
+13
View File
@@ -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;
+3 -3
View File
@@ -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);
+13
View File
@@ -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)):
+2 -2
View File
@@ -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
+9 -4
View File
@@ -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
+1 -1
View File
@@ -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;
+6 -6
View File
@@ -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;
}
+4 -4
View File
@@ -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;
+1 -1
View File
@@ -232,7 +232,7 @@ public:
log_img.release();
float key = (log_max - log_mean) / (log_max - log_min);
float map_key = 0.3f + 0.7f * pow(key, 1.4f);
float map_key = 0.3f + 0.7f * std::pow(key, 1.4f);
intensity = exp(-intensity);
Scalar chan_mean = mean(img);
float gray_mean = static_cast<float>(mean(gray_img)[0]);
@@ -397,6 +397,7 @@ NODES_TO_REFINE = {
SymbolName(("cv", ), (), "solvePnPRefineVVS"): make_optional_arg("distCoeffs"),
SymbolName(("cv", ), (), "undistort"): make_optional_arg("distCoeffs"),
SymbolName(("cv", ), (), "undistortPoints"): make_optional_arg("distCoeffs"),
SymbolName(("cv", ), (), "calibrateCamera"): make_optional_arg("cameraMatrix", "distCoeffs"),
SymbolName(("cv", "fisheye"), (), "initUndistortRectifyMap"): make_optional_arg("D"),
SymbolName(("cv", ), (), "imread"): make_optional_none_return,
SymbolName(("cv", ), (), "imdecode"): make_optional_none_return,
+1 -1
View File
@@ -55,7 +55,7 @@ class fitline_test(NewOpenCVTests):
for name in dist_func_names:
func = getattr(cv, name)
vx, vy, cx, cy = cv.fitLine(np.float32(points), func, 0, 0.01, 0.01)
line = [float(vx), float(vy), float(cx), float(cy)]
line = [vx[0], vy[0], cx[0], cy[0]]
lines.append(line)
eps = 0.05
+7 -7
View File
@@ -8,6 +8,7 @@ from __future__ import print_function
import numpy as np
import cv2 as cv
import random
from tests_common import NewOpenCVTests
@@ -31,20 +32,19 @@ class mser_test(NewOpenCVTests):
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
]
thresharr = [ 0, 70, 120, 180, 255 ]
kDelta = 5
mserExtractor = cv.MSER_create()
mserExtractor.setDelta(kDelta)
mserExtractor.setMinDiversity(0)
np.random.seed(10)
random.seed(10)
for _i in range(100):
use_big_image = int(np.random.rand(1,1)*7) != 0
invert = int(np.random.rand(1,1)*2) != 0
binarize = int(np.random.rand(1,1)*5) != 0 if use_big_image else False
blur = int(np.random.rand(1,1)*2) != 0
thresh = thresharr[int(np.random.rand(1,1)*5)]
use_big_image = random.choice([True, False])
invert = random.choice([True, False])
binarize = random.choice([True, False]) if use_big_image else False
blur = random.choice([True, False])
thresh = random.choice([0, 70, 120, 180, 255])
src0 = img if use_big_image else np.array(smallImg).astype('uint8')
src = src0.copy()
@@ -294,7 +294,7 @@ public:
*/
CV_WRAP Status stitch(InputArrayOfArrays images, InputArrayOfArrays masks, OutputArray pano);
/** @brief Returns indeces of input images used in panorama stitching
/** @brief Returns indices of input images used in panorama stitching
*/
CV_WRAP std::vector<int> component() const { return indices_; }
+1 -1
View File
@@ -156,7 +156,7 @@ bool calibrateRotatingCamera(const std::vector<Mat> &Hs, Mat &K)
for (int i = 0; i < m; ++i)
{
CV_Assert(Hs[i].size() == Size(3, 3) && Hs[i].type() == CV_64F);
Hs_[i] = Hs[i] / std::pow(determinant(Hs[i]), 1./3.);
Hs_[i] = Hs[i] / std::cbrt(determinant(Hs[i]));
}
const int idx_map[3][3] = {{0, 1, 2}, {1, 3, 4}, {2, 4, 5}};
+1 -1
View File
@@ -217,7 +217,7 @@ static void project_onto_jacobian_ECC(const Mat& src1, const Mat& src2, Mat& dst
Mat mat;
for (int i = 0; i < dst.rows; i++) {
mat = Mat(src1.colRange(i * w, (i + 1) * w));
dstPtr[i * (dst.rows + 1)] = (float)pow(norm(mat), 2); // diagonal elements
dstPtr[i * (dst.rows + 1)] = (float)std::pow(norm(mat), 2); // diagonal elements
for (int j = i + 1; j < dst.cols; j++) { // j starts from i+1
dstPtr[i * dst.cols + j] = (float)mat.dot(src2.colRange(j * w, (j + 1) * w));
@@ -286,8 +286,8 @@ void ClfOnlineStump::update(const Mat& posx, const Mat& negx, const Mat_<float>&
_q = (_mu1 - _mu0) / 2;
_s = sign(_mu1 - _mu0);
_log_n0 = std::log(float(1.0f / pow(_sig0, 0.5f)));
_log_n1 = std::log(float(1.0f / pow(_sig1, 0.5f)));
_log_n0 = std::log(float(1.0f / std::pow(_sig0, 0.5f)));
_log_n1 = std::log(float(1.0f / std::pow(_sig1, 0.5f)));
//_e1 = -1.0f/(2.0f*_sig1+1e-99f);
//_e0 = -1.0f/(2.0f*_sig0+1e-99f);
_e1 = -1.0f / (2.0f * _sig1 + std::numeric_limits<float>::min());
@@ -314,8 +314,8 @@ void ClfOnlineStump::update(const Mat& posx, const Mat& negx, const Mat_<float>&
_q = (_mu1 - _mu0) / 2;
_s = sign(_mu1 - _mu0);
_log_n0 = std::log(float(1.0f / pow(_sig0, 0.5f)));
_log_n1 = std::log(float(1.0f / pow(_sig1, 0.5f)));
_log_n0 = std::log(float(1.0f / std::pow(_sig0, 0.5f)));
_log_n1 = std::log(float(1.0f / std::pow(_sig1, 0.5f)));
//_e1 = -1.0f/(2.0f*_sig1+1e-99f);
//_e0 = -1.0f/(2.0f*_sig0+1e-99f);
_e1 = -1.0f / (2.0f * _sig1 + std::numeric_limits<float>::min());
+1 -1
View File
@@ -414,7 +414,7 @@ void testECCProperties(Mat x, float eps) {
EXPECT_NEAR(computeECC(X, 2 * Y + X), 1.0 / sqrt(5.0), eps);
}
TEST(Video_ECC_Test_Compute, properies) {
TEST(Video_ECC_Test_Compute, properties) {
Mat xline(1, 100, CV_32F), x;
for (int i = 0; i < xline.cols; ++i) xline.at<float>(0, i) = (float)i;
@@ -65,9 +65,6 @@
////////////////////////////////// video io /////////////////////////////////
typedef struct CvCapture CvCapture;
typedef struct CvVideoWriter CvVideoWriter;
namespace cv
{
@@ -1041,7 +1038,6 @@ public:
int64 timeoutNs = 0);
protected:
Ptr<CvCapture> cap;
Ptr<IVideoCapture> icap;
bool throwOnFail;
@@ -1220,18 +1216,12 @@ public:
CV_WRAP String getBackendName() const;
protected:
Ptr<CvVideoWriter> writer;
Ptr<IVideoWriter> iwriter;
static Ptr<IVideoWriter> create(const String& filename, int fourcc, double fps,
Size frameSize, bool isColor = true);
};
//! @cond IGNORED
template<> struct DefaultDeleter<CvCapture>{ CV_EXPORTS void operator ()(CvCapture* obj) const; };
template<> struct DefaultDeleter<CvVideoWriter>{ CV_EXPORTS void operator ()(CvVideoWriter* obj) const; };
//! @endcond IGNORED
//! @} videoio
} // cv
+4 -4
View File
@@ -228,7 +228,7 @@ bool VideoCapture::open(const String& filename, int apiPreference, const std::ve
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong. "
CV_LOG_DEBUG(NULL, "VIDEOIO: chosen backend does not work or wrong. "
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
@@ -353,7 +353,7 @@ bool VideoCapture::open(const Ptr<IStreamReader>& stream, int apiPreference, con
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong. "
CV_LOG_DEBUG(NULL, "VIDEOIO: chosen backend does not work or wrong. "
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
@@ -491,7 +491,7 @@ bool VideoCapture::open(int cameraNum, int apiPreference, const std::vector<int>
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong."
CV_LOG_DEBUG(NULL, "VIDEOIO: chosen backend does not work or wrong."
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
@@ -808,7 +808,7 @@ bool VideoWriter::open(const String& filename, int apiPreference, int fourcc, do
}
else
{
CV_LOG_DEBUG(NULL, "VIDEOIO: choosen backend does not work or wrong."
CV_LOG_DEBUG(NULL, "VIDEOIO: chosen backend does not work or wrong."
"Please make sure that your computer support chosen backend and OpenCV built "
"with right flags.");
}
+1 -1
View File
@@ -383,7 +383,7 @@ void CvCaptureCAM_Aravis::autoExposureControl(const Mat & image)
midGrey = brightness;
double maxe = 1e6 / fps;
double ne = CLIP( ( exposure * d ) / ( dmid * pow(sqrt(2), -2 * exposureCompensation) ), exposureMin, maxe);
double ne = CLIP( ( exposure * d ) / ( dmid * std::pow(sqrt(2), -2 * exposureCompensation) ), exposureMin, maxe);
// if change of value requires intervention
if(std::fabs(d-dmid) > 5) {
+8 -9
View File
@@ -488,9 +488,9 @@ bool GStreamerCapture::configureStreamsProperty(const cv::VideoCaptureParameters
{
if (params.has(CAP_PROP_VIDEO_STREAM))
{
double value = params.get<double>(CAP_PROP_VIDEO_STREAM);
gint value = params.get<gint>(CAP_PROP_VIDEO_STREAM);
if (value == -1 || value == 0)
videoStream = static_cast<gint>(value);
videoStream = value;
else
{
CV_LOG_ERROR(NULL, "VIDEOIO/Gstreamer: CAP_PROP_VIDEO_STREAM parameter value is invalid/unsupported: " << value);
@@ -499,9 +499,9 @@ bool GStreamerCapture::configureStreamsProperty(const cv::VideoCaptureParameters
}
if (params.has(CAP_PROP_AUDIO_STREAM))
{
double value = params.get<double>(CAP_PROP_AUDIO_STREAM);
if (value == -1 || value > -1)
audioStream = static_cast<gint>(value);
gint value = params.get<gint>(CAP_PROP_AUDIO_STREAM);
if (value == -1 || value >= 0)
audioStream = value;
else
{
CV_LOG_ERROR(NULL, "VIDEOIO/Gstreamer: CAP_PROP_AUDIO_STREAM parameter value is invalid/unsupported: " << value);
@@ -515,7 +515,7 @@ bool GStreamerCapture::setAudioProperties(const cv::VideoCaptureParameters& para
{
if (params.has(CAP_PROP_AUDIO_DATA_DEPTH))
{
gint value = static_cast<gint>(params.get<double>(CAP_PROP_AUDIO_DATA_DEPTH));
gint value = params.get<gint>(CAP_PROP_AUDIO_DATA_DEPTH);
if (value != CV_8S && value != CV_16S && value != CV_32S && value != CV_32F)
{
CV_LOG_ERROR(NULL, "VIDEOIO/Gstreamer: CAP_PROP_AUDIO_DATA_DEPTH parameter value is invalid/unsupported: " << value);
@@ -528,7 +528,7 @@ bool GStreamerCapture::setAudioProperties(const cv::VideoCaptureParameters& para
}
if (params.has(CAP_PROP_AUDIO_SAMPLES_PER_SECOND))
{
int value = static_cast<int>(params.get<double>(CAP_PROP_AUDIO_SAMPLES_PER_SECOND));
int value = params.get<int>(CAP_PROP_AUDIO_SAMPLES_PER_SECOND);
if (value < 0)
{
CV_LOG_ERROR(NULL, "VIDEOIO/Gstreamer: CAP_PROP_AUDIO_SAMPLES_PER_SECOND parameter can't be negative: " << value);
@@ -541,8 +541,7 @@ bool GStreamerCapture::setAudioProperties(const cv::VideoCaptureParameters& para
}
if (params.has(CAP_PROP_AUDIO_SYNCHRONIZE))
{
int value = static_cast<uint32_t>(params.get<double>(CAP_PROP_AUDIO_SYNCHRONIZE));
syncLastFrame = (value != 0) ? true : false;
syncLastFrame = params.get<bool>(CAP_PROP_AUDIO_SYNCHRONIZE);
}
return true;
}
+2 -2
View File
@@ -21,11 +21,11 @@ static float estimateBitrate(int codecId, size_t pixelNum, float fps)
}
else if (codecId == MFX_CODEC_AVC)
{
bitrate = (mp * 140 + 19) * pow(fps, 0.60f);
bitrate = (mp * 140 + 19) * std::pow(fps, 0.60f);
}
else if (codecId == MFX_CODEC_HEVC)
{
bitrate = (mp * 63 + 45) * pow(fps, 0.60f);
bitrate = (mp * 63 + 45) * std::pow(fps, 0.60f);
}
else
{
+26 -27
View File
@@ -789,7 +789,7 @@ protected:
bool checkAudioProperties();
template <typename CtrlT>
bool readComplexPropery(long prop, long& val) const;
bool readComplexProperty(long prop, long& val) const;
template <typename CtrlT>
bool writeComplexProperty(long prop, double val, long flags);
_ComPtr<IMFAttributes> getDefaultSourceConfig(UINT32 num = 10);
@@ -1388,9 +1388,9 @@ bool CvCapture_MSMF::configureStreams(const cv::VideoCaptureParameters& params)
{
if (params.has(CAP_PROP_VIDEO_STREAM))
{
double value = params.get<double>(CAP_PROP_VIDEO_STREAM);
int value = params.get<int>(CAP_PROP_VIDEO_STREAM);
if (value == -1 || value == 0)
videoStream = static_cast<int>(value);
videoStream = value;
else
{
CV_LOG_ERROR(NULL, "VIDEOIO/MSMF: CAP_PROP_VIDEO_STREAM parameter value is invalid/unsupported: " << value);
@@ -1399,8 +1399,8 @@ bool CvCapture_MSMF::configureStreams(const cv::VideoCaptureParameters& params)
}
if (params.has(CAP_PROP_AUDIO_STREAM))
{
double value = params.get<double>(CAP_PROP_AUDIO_STREAM);
if (value == -1 || value > -1)
int value = params.get<int>(CAP_PROP_AUDIO_STREAM);
if (value == -1 || value >= 0)
audioStream = static_cast<int>(value);
else
{
@@ -1414,7 +1414,7 @@ bool CvCapture_MSMF::setAudioProperties(const cv::VideoCaptureParameters& params
{
if (params.has(CAP_PROP_AUDIO_DATA_DEPTH))
{
int value = static_cast<int>(params.get<double>(CAP_PROP_AUDIO_DATA_DEPTH));
int value = params.get<int>(CAP_PROP_AUDIO_DATA_DEPTH);
if (value != CV_8S && value != CV_16S && value != CV_32S && value != CV_32F)
{
CV_LOG_ERROR(NULL, "VIDEOIO/MSMF: CAP_PROP_AUDIO_DATA_DEPTH parameter value is invalid/unsupported: " << value);
@@ -1427,7 +1427,7 @@ bool CvCapture_MSMF::setAudioProperties(const cv::VideoCaptureParameters& params
}
if (params.has(CAP_PROP_AUDIO_SAMPLES_PER_SECOND))
{
int value = static_cast<int>(params.get<double>(CAP_PROP_AUDIO_SAMPLES_PER_SECOND));
int value = params.get<int>(CAP_PROP_AUDIO_SAMPLES_PER_SECOND);
if (value < 0)
{
CV_LOG_ERROR(NULL, "VIDEOIO/MSMF: CAP_PROP_AUDIO_SAMPLES_PER_SECOND parameter can't be negative: " << value);
@@ -1440,8 +1440,7 @@ bool CvCapture_MSMF::setAudioProperties(const cv::VideoCaptureParameters& params
}
if (params.has(CAP_PROP_AUDIO_SYNCHRONIZE))
{
int value = static_cast<UINT32>(params.get<double>(CAP_PROP_AUDIO_SYNCHRONIZE));
syncLastFrame = (value != 0) ? true : false;
syncLastFrame = params.get<bool>(CAP_PROP_AUDIO_SYNCHRONIZE);
}
return true;
}
@@ -2120,7 +2119,7 @@ bool CvCapture_MSMF::setTime(int numberFrame)
}
template <typename CtrlT>
bool CvCapture_MSMF::readComplexPropery(long prop, long & val) const
bool CvCapture_MSMF::readComplexProperty(long prop, long & val) const
{
_ComPtr<CtrlT> ctrl;
if (FAILED(videoFileSource->GetServiceForStream((DWORD)MF_SOURCE_READER_MEDIASOURCE, GUID_NULL, IID_PPV_ARGS(&ctrl))))
@@ -2188,64 +2187,64 @@ double CvCapture_MSMF::getProperty( int property_id ) const
else
break;
case CAP_PROP_BRIGHTNESS:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Brightness, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Brightness, cVal))
return cVal;
break;
case CAP_PROP_CONTRAST:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Contrast, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Contrast, cVal))
return cVal;
break;
case CAP_PROP_SATURATION:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Saturation, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Saturation, cVal))
return cVal;
break;
case CAP_PROP_HUE:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Hue, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Hue, cVal))
return cVal;
break;
case CAP_PROP_GAIN:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Gain, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Gain, cVal))
return cVal;
break;
case CAP_PROP_SHARPNESS:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Sharpness, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Sharpness, cVal))
return cVal;
break;
case CAP_PROP_GAMMA:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_Gamma, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_Gamma, cVal))
return cVal;
break;
case CAP_PROP_BACKLIGHT:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_BacklightCompensation, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_BacklightCompensation, cVal))
return cVal;
break;
case CAP_PROP_MONOCHROME:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_ColorEnable, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_ColorEnable, cVal))
return cVal == 0 ? 1 : 0;
break;
case CAP_PROP_TEMPERATURE:
if (readComplexPropery<IAMVideoProcAmp>(VideoProcAmp_WhiteBalance, cVal))
if (readComplexProperty<IAMVideoProcAmp>(VideoProcAmp_WhiteBalance, cVal))
return cVal;
break;
case CAP_PROP_PAN:
if (readComplexPropery<IAMCameraControl>(CameraControl_Pan, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Pan, cVal))
return cVal;
break;
case CAP_PROP_TILT:
if (readComplexPropery<IAMCameraControl>(CameraControl_Tilt, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Tilt, cVal))
return cVal;
break;
case CAP_PROP_ROLL:
if (readComplexPropery<IAMCameraControl>(CameraControl_Roll, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Roll, cVal))
return cVal;
break;
case CAP_PROP_IRIS:
if (readComplexPropery<IAMCameraControl>(CameraControl_Iris, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Iris, cVal))
return cVal;
break;
case CAP_PROP_EXPOSURE:
case CAP_PROP_AUTO_EXPOSURE:
if (readComplexPropery<IAMCameraControl>(CameraControl_Exposure, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Exposure, cVal))
{
if (property_id == CAP_PROP_EXPOSURE)
return cVal;
@@ -2254,12 +2253,12 @@ double CvCapture_MSMF::getProperty( int property_id ) const
}
break;
case CAP_PROP_ZOOM:
if (readComplexPropery<IAMCameraControl>(CameraControl_Zoom, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Zoom, cVal))
return cVal;
break;
case CAP_PROP_FOCUS:
case CAP_PROP_AUTOFOCUS:
if (readComplexPropery<IAMCameraControl>(CameraControl_Focus, cVal))
if (readComplexProperty<IAMCameraControl>(CameraControl_Focus, cVal))
{
if (property_id == CAP_PROP_FOCUS)
return cVal;
@@ -42,9 +42,9 @@ VideoCapture_obsensor::VideoCapture_obsensor(int, const cv::VideoCaptureParamete
alignFilter = std::make_shared<ob::Align>(OB_STREAM_COLOR);
#endif
int color_width = params.get<double>(CAP_PROP_FRAME_WIDTH, OB_WIDTH_ANY);
int color_height = params.get<double>(CAP_PROP_FRAME_HEIGHT, OB_HEIGHT_ANY);
int color_fps = params.get<double>(CAP_PROP_FPS, OB_FPS_ANY);
int color_width = params.get<int>(CAP_PROP_FRAME_WIDTH, OB_WIDTH_ANY);
int color_height = params.get<int>(CAP_PROP_FRAME_HEIGHT, OB_HEIGHT_ANY);
int color_fps = params.get<int>(CAP_PROP_FPS, OB_FPS_ANY);
auto colorProfiles = pipe->getStreamProfileList(OB_SENSOR_COLOR);
if (color_width == OB_WIDTH_ANY && color_height == OB_HEIGHT_ANY && color_fps == OB_FPS_ANY)
@@ -60,9 +60,9 @@ VideoCapture_obsensor::VideoCapture_obsensor(int, const cv::VideoCaptureParamete
config->enableStream(colorProfile->as<ob::VideoStreamProfile>());
}
int depth_width = params.get<double>(CAP_PROP_OBSENSOR_DEPTH_WIDTH, OB_WIDTH_ANY);
int depth_height = params.get<double>(CAP_PROP_OBSENSOR_DEPTH_HEIGHT, OB_HEIGHT_ANY);
int depth_fps = params.get<double>(CAP_PROP_OBSENSOR_DEPTH_FPS, OB_FPS_ANY);
int depth_width = params.get<int>(CAP_PROP_OBSENSOR_DEPTH_WIDTH, OB_WIDTH_ANY);
int depth_height = params.get<int>(CAP_PROP_OBSENSOR_DEPTH_HEIGHT, OB_HEIGHT_ANY);
int depth_fps = params.get<int>(CAP_PROP_OBSENSOR_DEPTH_FPS, OB_FPS_ANY);
auto depthProfiles = pipe->getStreamProfileList(OB_SENSOR_DEPTH);
if (depth_width == OB_WIDTH_ANY && depth_height == OB_HEIGHT_ANY && depth_fps == OB_FPS_ANY)