Warning fixes continued

This commit is contained in:
Andrey Kamaev 2012-06-09 15:00:04 +00:00
parent f6b451c607
commit f2d3b9b4a1
127 changed files with 6298 additions and 6277 deletions

View File

@ -75,7 +75,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
#add_extra_compiler_option(-Wcast-align)
#add_extra_compiler_option(-Wstrict-aliasing=2)
#add_extra_compiler_option(-Wshadow)
add_extra_compiler_option(-Wno-unnamed-type-template-args)
#add_extra_compiler_option(-Wno-unnamed-type-template-args)
# The -Wno-long-long is required in 64bit systems when including sytem headers.
if(X86_64)

View File

@ -10,7 +10,7 @@ elseif(UNIX AND NOT APPLE)
if(TBB_FOUND)
set(HAVE_TBB 1)
if(NOT ${TBB_INCLUDE_DIRS} STREQUAL "")
include_directories(SYSTEM ${TBB_INCLUDE_DIRS})
ocv_include_directories(${TBB_INCLUDE_DIRS})
endif()
link_directories(${TBB_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${TBB_LIBRARIES})
@ -63,7 +63,7 @@ if(NOT HAVE_TBB)
set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIRS}" STREQUAL "")
include_directories(SYSTEM "${TBB_INCLUDE_DIRS}")
ocv_include_directories("${TBB_INCLUDE_DIRS}")
endif()
endif(TBB_INCLUDE_DIRS)
endif(NOT HAVE_TBB)

View File

@ -19,7 +19,7 @@ function(ocv_include_directories)
if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
list(APPEND __add_before "${dir}")
else()
include_directories(AFTER "${dir}")
include_directories(AFTER SYSTEM "${dir}")
endif()
endforeach()
include_directories(BEFORE ${__add_before})

View File

@ -255,7 +255,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
IplImage _img;
int check_chessboard_result;
int quad_count = 0, group_idx = 0, i = 0, dilations = 0;
int quad_count = 0, group_idx = 0, dilations = 0;
img = cvGetMat( img, &stub );
//debug_img = img;
@ -316,7 +316,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
for( dilations = min_dilations; dilations <= max_dilations; dilations++ )
{
if (found)
break; // already found it
break; // already found it
cvFree(&quads);
cvFree(&corners);
@ -378,7 +378,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
cvCopy(dbg_img, dbg1_img);
cvNamedWindow("all_quads", 1);
// copy corners to temp array
for( i = 0; i < quad_count; i++ )
for(int i = 0; i < quad_count; i++ )
{
for (int k=0; k<4; k++)
{
@ -432,7 +432,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
cvCopy(dbg_img,dbg2_img);
cvNamedWindow("connected_group", 1);
// copy corners to temp array
for( i = 0; i < quad_count; i++ )
for(int i = 0; i < quad_count; i++ )
{
if (quads[i].group_idx == group_idx)
for (int k=0; k<4; k++)
@ -455,7 +455,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
#endif
if (count == 0)
continue; // haven't found inner quads
continue; // haven't found inner quads
// If count is more than it should be, this will remove those quads
@ -472,7 +472,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
float sum_dist = 0;
int total = 0;
for( i = 0; i < n; i++ )
for(int i = 0; i < n; i++ )
{
int ni = 0;
float avgi = corner_group[i]->meanDist(&ni);
@ -484,7 +484,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
if( count > 0 || (out_corner_count && -count > *out_corner_count) )
{
// copy corners to output array
for( i = 0; i < n; i++ )
for(int i = 0; i < n; i++ )
out_corners[i] = corner_group[i]->pt;
if( out_corner_count )
@ -505,19 +505,19 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
if( found )
found = icvCheckBoardMonotony( out_corners, pattern_size );
// check that none of the found corners is too close to the image boundary
// check that none of the found corners is too close to the image boundary
if( found )
{
const int BORDER = 8;
for( k = 0; k < pattern_size.width*pattern_size.height; k++ )
{
if( out_corners[k].x <= BORDER || out_corners[k].x > img->cols - BORDER ||
out_corners[k].y <= BORDER || out_corners[k].y > img->rows - BORDER )
break;
}
{
const int BORDER = 8;
for( k = 0; k < pattern_size.width*pattern_size.height; k++ )
{
if( out_corners[k].x <= BORDER || out_corners[k].x > img->cols - BORDER ||
out_corners[k].y <= BORDER || out_corners[k].y > img->rows - BORDER )
break;
}
found = k == pattern_size.width*pattern_size.height;
}
found = k == pattern_size.width*pattern_size.height;
}
if( found && pattern_size.height % 2 == 0 && pattern_size.width % 2 == 0 )
{
@ -525,8 +525,8 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
double dy0 = out_corners[last_row].y - out_corners[0].y;
if( dy0 < 0 )
{
int i, n = pattern_size.width*pattern_size.height;
for( i = 0; i < n/2; i++ )
int n = pattern_size.width*pattern_size.height;
for(int i = 0; i < n/2; i++ )
{
CvPoint2D32f temp;
CV_SWAP(out_corners[i], out_corners[n-i-1], temp);
@ -627,11 +627,10 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
{
cv::Ptr<CvMemStorage> temp_storage = cvCreateChildMemStorage( storage );
CvSeq* stack = cvCreateSeq( 0, sizeof(*stack), sizeof(void*), temp_storage );
int i;
// first find an interior quad
CvCBQuad *start = NULL;
for (i=0; i<quad_count; i++)
for (int i=0; i<quad_count; i++)
{
if (quads[i]->count == 4)
{
@ -682,7 +681,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
case 1:
col += 2; break;
case 2:
row += 2; break;
row += 2; break;
case 3:
col -= 2; break;
}
@ -700,7 +699,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
}
}
for (i=col_min; i<=col_max; i++)
for (int i=col_min; i<=col_max; i++)
PRINTF("HIST[%d] = %d\n", i, col_hist[i]);
// analyze inner quad structure
@ -763,7 +762,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
// if there is an outer quad missing, fill it in
// first order all inner quads
int found = 0;
for (i=0; i<quad_count; i++)
for (int i=0; i<quad_count; i++)
{
if (quads[i]->count == 4)
{ // ok, look at neighbors
@ -778,7 +777,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
case 1:
col += 2; break;
case 2:
row += 2; break;
row += 2; break;
case 3:
col -= 2; break;
}
@ -817,7 +816,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
// final trimming of outer quads
if (dcol == w && drow == h) // found correct inner quads
if (dcol == w && drow == h) // found correct inner quads
{
PRINTF("Inner bounds ok, check outer quads\n");
int rcount = quad_count;
@ -832,7 +831,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads,
if (quads[i]->neighbors[j] && quads[i]->neighbors[j]->ordered)
outer = true;
}
if (!outer) // not an outer quad, eliminate
if (!outer) // not an outer quad, eliminate
{
PRINTF("Removing quad %d\n", i);
icvRemoveQuadFromGroup(quads,rcount,quads[i]);
@ -876,7 +875,7 @@ icvAddOuterQuad( CvCBQuad *quad, CvCBQuad **quads, int quad_count,
quad->count += 1;
q->neighbors[j] = quad;
q->group_idx = quad->group_idx;
q->count = 1; // number of neighbors
q->count = 1; // number of neighbors
q->ordered = false;
q->edge_len = quad->edge_len;
@ -2006,17 +2005,17 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
#endif
if (isFound)
{
switch(parameters.gridType)
{
switch(parameters.gridType)
{
case CirclesGridFinderParameters::SYMMETRIC_GRID:
boxFinder.getHoles(centers);
break;
case CirclesGridFinderParameters::ASYMMETRIC_GRID:
boxFinder.getAsymmetricHoles(centers);
break;
boxFinder.getAsymmetricHoles(centers);
break;
default:
CV_Error(CV_StsBadArg, "Unkown pattern type");
}
}
if (i != 0)
{

View File

@ -1153,7 +1153,7 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints,
int useExtrinsicGuess )
{
const int max_iter = 20;
Ptr<CvMat> matM, _Mxy, _m, _mn, matL, matJ;
Ptr<CvMat> matM, _Mxy, _m, _mn, matL;
int i, count;
double a[9], ar[9]={1,0,0,0,1,0,0,0,1}, R[9];

View File

@ -65,14 +65,14 @@ void drawPoints(const vector<Point2f> &points, Mat &outImage, int radius = 2, S
}
#endif
void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> points, const Size &patternSize, vector<Point2f> &patternPoints)
void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> points, const Size &patternSz, vector<Point2f> &patternPoints)
{
#ifdef HAVE_TEGRA_OPTIMIZATION
if(tegra::hierarchicalClustering(points, patternSize, patternPoints))
if(tegra::hierarchicalClustering(points, patternSz, patternPoints))
return;
#endif
int i, j, n = (int)points.size();
size_t pn = static_cast<size_t>(patternSize.area());
int j, n = (int)points.size();
size_t pn = static_cast<size_t>(patternSz.area());
patternPoints.clear();
if (pn >= points.size())
@ -84,7 +84,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> poin
Mat dists(n, n, CV_32FC1, Scalar(0));
Mat distsMask(dists.size(), CV_8UC1, Scalar(0));
for(i = 0; i < n; i++)
for(int i = 0; i < n; i++)
{
for(j = i+1; j < n; j++)
{
@ -122,7 +122,7 @@ void CirclesGridClusterFinder::hierarchicalClustering(const vector<Point2f> poin
}
//the largest cluster can have more than pn points -- we need to filter out such situations
if(clusters[patternClusterIdx].size() != static_cast<size_t>(patternSize.area()))
if(clusters[patternClusterIdx].size() != static_cast<size_t>(patternSz.area()))
{
return;
}
@ -505,11 +505,11 @@ void Graph::floydWarshall(cv::Mat &distanceMatrix, int infinity) const
{
for (Vertices::const_iterator it3 = vertices.begin(); it3 != vertices.end(); it3++)
{
int i1 = (int)it1->first, i2 = (int)it2->first, i3 = (int)it3->first;
int i1 = (int)it1->first, i2 = (int)it2->first, i3 = (int)it3->first;
int val1 = distanceMatrix.at<int> (i2, i3);
int val2;
if (distanceMatrix.at<int> (i2, i1) == infinity ||
distanceMatrix.at<int> (i1, i3) == infinity)
distanceMatrix.at<int> (i1, i3) == infinity)
val2 = val1;
else
{

View File

@ -8,7 +8,7 @@ epnp::epnp(const cv::Mat& cameraMatrix, const cv::Mat& opoints, const cv::Mat& i
if (cameraMatrix.depth() == CV_32F)
init_camera_parameters<float>(cameraMatrix);
else
init_camera_parameters<double>(cameraMatrix);
init_camera_parameters<double>(cameraMatrix);
number_of_correspondences = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
@ -17,15 +17,15 @@ epnp::epnp(const cv::Mat& cameraMatrix, const cv::Mat& opoints, const cv::Mat& i
if (opoints.depth() == ipoints.depth())
{
if (opoints.depth() == CV_32F)
init_points<cv::Point3f,cv::Point2f>(opoints, ipoints);
else
init_points<cv::Point3d,cv::Point2d>(opoints, ipoints);
if (opoints.depth() == CV_32F)
init_points<cv::Point3f,cv::Point2f>(opoints, ipoints);
else
init_points<cv::Point3d,cv::Point2d>(opoints, ipoints);
}
else if (opoints.depth() == CV_32F)
init_points<cv::Point3f,cv::Point2d>(opoints, ipoints);
init_points<cv::Point3f,cv::Point2d>(opoints, ipoints);
else
init_points<cv::Point3d,cv::Point2f>(opoints, ipoints);
init_points<cv::Point3d,cv::Point2f>(opoints, ipoints);
alphas.resize(4 * number_of_correspondences);
pcs.resize(3 * number_of_correspondences);
@ -97,15 +97,15 @@ void epnp::compute_barycentric_coordinates(void)
for(int j = 0; j < 3; j++)
a[1 + j] =
ci[3 * j ] * (pi[0] - cws[0][0]) +
ci[3 * j + 1] * (pi[1] - cws[0][1]) +
ci[3 * j + 2] * (pi[2] - cws[0][2]);
ci[3 * j ] * (pi[0] - cws[0][0]) +
ci[3 * j + 1] * (pi[1] - cws[0][1]) +
ci[3 * j + 2] * (pi[2] - cws[0][2]);
a[0] = 1.0f - a[1] - a[2] - a[3];
}
}
void epnp::fill_M(CvMat * M,
const int row, const double * as, const double u, const double v)
const int row, const double * as, const double u, const double v)
{
double * M1 = M->data.db + row * 12;
double * M2 = M1 + 12;
@ -130,7 +130,7 @@ void epnp::compute_ccs(const double * betas, const double * ut)
const double * v = ut + 12 * (11 - i);
for(int j = 0; j < 4; j++)
for(int k = 0; k < 3; k++)
ccs[j][k] += betas[i] * v[3 * j + k];
ccs[j][k] += betas[i] * v[3 * j + k];
}
}
@ -195,7 +195,7 @@ void epnp::compute_pose(cv::Mat& R, cv::Mat& t)
}
void epnp::copy_R_and_t(const double R_src[3][3], const double t_src[3],
double R_dst[3][3], double t_dst[3])
double R_dst[3][3], double t_dst[3])
{
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++)
@ -282,7 +282,7 @@ void epnp::solve_for_sign(void)
if (pcs[2] < 0.0) {
for(int i = 0; i < 4; i++)
for(int j = 0; j < 3; j++)
ccs[i][j] = -ccs[i][j];
ccs[i][j] = -ccs[i][j];
for(int i = 0; i < number_of_correspondences; i++) {
pcs[3 * i ] = -pcs[3 * i];
@ -293,7 +293,7 @@ void epnp::solve_for_sign(void)
}
double epnp::compute_R_and_t(const double * ut, const double * betas,
double R[3][3], double t[3])
double R[3][3], double t[3])
{
compute_ccs(betas, ut);
compute_pcs();
@ -328,7 +328,7 @@ double epnp::reprojection_error(const double R[3][3], const double t[3])
// betas_approx_1 = [B11 B12 B13 B14]
void epnp::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
double * betas)
{
double l_6x4[6 * 4], b4[4];
CvMat L_6x4 = cvMat(6, 4, CV_64F, l_6x4);
@ -360,7 +360,7 @@ void epnp::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho,
// betas_approx_2 = [B11 B12 B22 ]
void epnp::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
double * betas)
{
double l_6x3[6 * 3], b3[3];
CvMat L_6x3 = cvMat(6, 3, CV_64F, l_6x3);
@ -392,7 +392,7 @@ void epnp::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho,
// betas_approx_3 = [B11 B12 B22 B13 B23 ]
void epnp::find_betas_approx_3(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
double * betas)
{
double l_6x5[6 * 5], b5[5];
CvMat L_6x5 = cvMat(6, 5, CV_64F, l_6x5);
@ -440,8 +440,8 @@ void epnp::compute_L_6x10(const double * ut, double * l_6x10)
b++;
if (b > 3) {
a++;
b = a + 1;
a++;
b = a + 1;
}
}
}
@ -473,7 +473,7 @@ void epnp::compute_rho(double * rho)
}
void epnp::compute_A_and_b_gauss_newton(const double * l_6x10, const double * rho,
const double betas[4], CvMat * A, CvMat * b)
const double betas[4], CvMat * A, CvMat * b)
{
for(int i = 0; i < 6; i++) {
const double * rowL = l_6x10 + i * 10;
@ -485,23 +485,22 @@ void epnp::compute_A_and_b_gauss_newton(const double * l_6x10, const double * rh
rowA[3] = rowL[6] * betas[0] + rowL[7] * betas[1] + rowL[8] * betas[2] + 2 * rowL[9] * betas[3];
cvmSet(b, i, 0, rho[i] -
(
rowL[0] * betas[0] * betas[0] +
rowL[1] * betas[0] * betas[1] +
rowL[2] * betas[1] * betas[1] +
rowL[3] * betas[0] * betas[2] +
rowL[4] * betas[1] * betas[2] +
rowL[5] * betas[2] * betas[2] +
rowL[6] * betas[0] * betas[3] +
rowL[7] * betas[1] * betas[3] +
rowL[8] * betas[2] * betas[3] +
rowL[9] * betas[3] * betas[3]
));
(
rowL[0] * betas[0] * betas[0] +
rowL[1] * betas[0] * betas[1] +
rowL[2] * betas[1] * betas[1] +
rowL[3] * betas[0] * betas[2] +
rowL[4] * betas[1] * betas[2] +
rowL[5] * betas[2] * betas[2] +
rowL[6] * betas[0] * betas[3] +
rowL[7] * betas[1] * betas[3] +
rowL[8] * betas[2] * betas[3] +
rowL[9] * betas[3] * betas[3]
));
}
}
void epnp::gauss_newton(const CvMat * L_6x10, const CvMat * Rho,
double betas[4])
void epnp::gauss_newton(const CvMat * L_6x10, const CvMat * Rho, double betas[4])
{
const int iterations_number = 5;
@ -510,12 +509,13 @@ void epnp::gauss_newton(const CvMat * L_6x10, const CvMat * Rho,
CvMat B = cvMat(6, 1, CV_64F, b);
CvMat X = cvMat(4, 1, CV_64F, x);
for(int k = 0; k < iterations_number; k++) {
for(int k = 0; k < iterations_number; k++)
{
compute_A_and_b_gauss_newton(L_6x10->data.db, Rho->data.db,
betas, &A, &B);
betas, &A, &B);
qr_solve(&A, &B, &X);
for(int i = 0; i < 4; i++)
betas[i] += x[i];
betas[i] += x[i];
}
}
@ -524,53 +524,64 @@ void epnp::qr_solve(CvMat * A, CvMat * b, CvMat * X)
const int nr = A->rows;
const int nc = A->cols;
if (max_nr != 0 && max_nr < nr) {
if (max_nr != 0 && max_nr < nr)
{
delete [] A1;
delete [] A2;
}
if (max_nr < nr) {
if (max_nr < nr)
{
max_nr = nr;
A1 = new double[nr];
A2 = new double[nr];
}
double * pA = A->data.db, * ppAkk = pA;
for(int k = 0; k < nc; k++) {
double * ppAik = ppAkk, eta = fabs(*ppAik);
for(int i = k + 1; i < nr; i++) {
double elt = fabs(*ppAik);
for(int k = 0; k < nc; k++)
{
double * ppAik1 = ppAkk, eta = fabs(*ppAik1);
for(int i = k + 1; i < nr; i++)
{
double elt = fabs(*ppAik1);
if (eta < elt) eta = elt;
ppAik += nc;
ppAik1 += nc;
}
if (eta == 0) {
if (eta == 0)
{
A1[k] = A2[k] = 0.0;
//cerr << "God damnit, A is singular, this shouldn't happen." << endl;
return;
} else {
double * ppAik = ppAkk, sum = 0.0, inv_eta = 1. / eta;
for(int i = k; i < nr; i++) {
*ppAik *= inv_eta;
sum += *ppAik * *ppAik;
ppAik += nc;
}
else
{
double * ppAik2 = ppAkk, sum2 = 0.0, inv_eta = 1. / eta;
for(int i = k; i < nr; i++)
{
*ppAik2 *= inv_eta;
sum2 += *ppAik2 * *ppAik2;
ppAik2 += nc;
}
double sigma = sqrt(sum);
double sigma = sqrt(sum2);
if (*ppAkk < 0)
sigma = -sigma;
sigma = -sigma;
*ppAkk += sigma;
A1[k] = sigma * *ppAkk;
A2[k] = -eta * sigma;
for(int j = k + 1; j < nc; j++) {
double * ppAik = ppAkk, sum = 0;
for(int i = k; i < nr; i++) {
sum += *ppAik * ppAik[j - k];
ppAik += nc;
}
double tau = sum / A1[k];
ppAik = ppAkk;
for(int i = k; i < nr; i++) {
ppAik[j - k] -= tau * *ppAik;
ppAik += nc;
}
for(int j = k + 1; j < nc; j++)
{
double * ppAik = ppAkk, sum = 0;
for(int i = k; i < nr; i++)
{
sum += *ppAik * ppAik[j - k];
ppAik += nc;
}
double tau = sum / A1[k];
ppAik = ppAkk;
for(int i = k; i < nr; i++)
{
ppAik[j - k] -= tau * *ppAik;
ppAik += nc;
}
}
}
ppAkk += nc + 1;
@ -578,15 +589,18 @@ void epnp::qr_solve(CvMat * A, CvMat * b, CvMat * X)
// b <- Qt b
double * ppAjj = pA, * pb = b->data.db;
for(int j = 0; j < nc; j++) {
for(int j = 0; j < nc; j++)
{
double * ppAij = ppAjj, tau = 0;
for(int i = j; i < nr; i++) {
for(int i = j; i < nr; i++)
{
tau += *ppAij * pb[i];
ppAij += nc;
}
tau /= A1[j];
ppAij = ppAjj;
for(int i = j; i < nr; i++) {
for(int i = j; i < nr; i++)
{
pb[i] -= tau * *ppAij;
ppAij += nc;
}
@ -596,10 +610,12 @@ void epnp::qr_solve(CvMat * A, CvMat * b, CvMat * X)
// X = R-1 b
double * pX = X->data.db;
pX[nc - 1] = pb[nc - 1] / A2[nc - 1];
for(int i = nc - 2; i >= 0; i--) {
for(int i = nc - 2; i >= 0; i--)
{
double * ppAij = pA + i * nc + (i + 1), sum = 0;
for(int j = i + 1; j < nc; j++) {
for(int j = i + 1; j < nc; j++)
{
sum += *ppAij * pX[j];
ppAij++;
}

View File

@ -9,151 +9,151 @@ using namespace std;
void p3p::init_inverse_parameters()
{
inv_fx = 1. / fx;
inv_fy = 1. / fy;
cx_fx = cx / fx;
cy_fy = cy / fy;
inv_fx = 1. / fx;
inv_fy = 1. / fy;
cx_fx = cx / fx;
cy_fy = cy / fy;
}
p3p::p3p(cv::Mat cameraMatrix)
{
if (cameraMatrix.depth() == CV_32F)
init_camera_parameters<float>(cameraMatrix);
else
init_camera_parameters<double>(cameraMatrix);
init_inverse_parameters();
if (cameraMatrix.depth() == CV_32F)
init_camera_parameters<float>(cameraMatrix);
else
init_camera_parameters<double>(cameraMatrix);
init_inverse_parameters();
}
p3p::p3p(double _fx, double _fy, double _cx, double _cy)
{
fx = _fx;
fy = _fy;
cx = _cx;
cy = _cy;
init_inverse_parameters();
fx = _fx;
fy = _fy;
cx = _cx;
cy = _cy;
init_inverse_parameters();
}
bool p3p::solve(cv::Mat& R, cv::Mat& tvec, const cv::Mat& opoints, const cv::Mat& ipoints)
{
double rotation_matrix[3][3], translation[3];
std::vector<double> points;
if (opoints.depth() == ipoints.depth())
{
if (opoints.depth() == CV_32F)
extract_points<cv::Point3f,cv::Point2f>(opoints, ipoints, points);
else
extract_points<cv::Point3d,cv::Point2d>(opoints, ipoints, points);
}
else if (opoints.depth() == CV_32F)
extract_points<cv::Point3f,cv::Point2d>(opoints, ipoints, points);
else
extract_points<cv::Point3d,cv::Point2f>(opoints, ipoints, points);
double rotation_matrix[3][3], translation[3];
std::vector<double> points;
if (opoints.depth() == ipoints.depth())
{
if (opoints.depth() == CV_32F)
extract_points<cv::Point3f,cv::Point2f>(opoints, ipoints, points);
else
extract_points<cv::Point3d,cv::Point2d>(opoints, ipoints, points);
}
else if (opoints.depth() == CV_32F)
extract_points<cv::Point3f,cv::Point2d>(opoints, ipoints, points);
else
extract_points<cv::Point3d,cv::Point2f>(opoints, ipoints, points);
bool result = solve(rotation_matrix, translation, points[0], points[1], points[2], points[3], points[4], points[5],
points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13], points[14],
points[15], points[16], points[17], points[18], points[19]);
cv::Mat(3, 1, CV_64F, translation).copyTo(tvec);
bool result = solve(rotation_matrix, translation, points[0], points[1], points[2], points[3], points[4], points[5],
points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13], points[14],
points[15], points[16], points[17], points[18], points[19]);
cv::Mat(3, 1, CV_64F, translation).copyTo(tvec);
cv::Mat(3, 3, CV_64F, rotation_matrix).copyTo(R);
return result;
return result;
}
bool p3p::solve(double R[3][3], double t[3],
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
double mu2, double mv2, double X2, double Y2, double Z2,
double mu3, double mv3, double X3, double Y3, double Z3)
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
double mu2, double mv2, double X2, double Y2, double Z2,
double mu3, double mv3, double X3, double Y3, double Z3)
{
double Rs[4][3][3], ts[4][3];
double Rs[4][3][3], ts[4][3];
int n = solve(Rs, ts, mu0, mv0, X0, Y0, Z0, mu1, mv1, X1, Y1, Z1, mu2, mv2, X2, Y2, Z2);
int n = solve(Rs, ts, mu0, mv0, X0, Y0, Z0, mu1, mv1, X1, Y1, Z1, mu2, mv2, X2, Y2, Z2);
if (n == 0)
return false;
if (n == 0)
return false;
int ns = 0;
double min_reproj = 0;
for(int i = 0; i < n; i++) {
double X3p = Rs[i][0][0] * X3 + Rs[i][0][1] * Y3 + Rs[i][0][2] * Z3 + ts[i][0];
double Y3p = Rs[i][1][0] * X3 + Rs[i][1][1] * Y3 + Rs[i][1][2] * Z3 + ts[i][1];
double Z3p = Rs[i][2][0] * X3 + Rs[i][2][1] * Y3 + Rs[i][2][2] * Z3 + ts[i][2];
double mu3p = cx + fx * X3p / Z3p;
double mv3p = cy + fy * Y3p / Z3p;
double reproj = (mu3p - mu3) * (mu3p - mu3) + (mv3p - mv3) * (mv3p - mv3);
if (i == 0 || min_reproj > reproj) {
ns = i;
min_reproj = reproj;
}
}
int ns = 0;
double min_reproj = 0;
for(int i = 0; i < n; i++) {
double X3p = Rs[i][0][0] * X3 + Rs[i][0][1] * Y3 + Rs[i][0][2] * Z3 + ts[i][0];
double Y3p = Rs[i][1][0] * X3 + Rs[i][1][1] * Y3 + Rs[i][1][2] * Z3 + ts[i][1];
double Z3p = Rs[i][2][0] * X3 + Rs[i][2][1] * Y3 + Rs[i][2][2] * Z3 + ts[i][2];
double mu3p = cx + fx * X3p / Z3p;
double mv3p = cy + fy * Y3p / Z3p;
double reproj = (mu3p - mu3) * (mu3p - mu3) + (mv3p - mv3) * (mv3p - mv3);
if (i == 0 || min_reproj > reproj) {
ns = i;
min_reproj = reproj;
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++)
R[i][j] = Rs[ns][i][j];
t[i] = ts[ns][i];
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++)
R[i][j] = Rs[ns][i][j];
t[i] = ts[ns][i];
}
return true;
return true;
}
int p3p::solve(double R[4][3][3], double t[4][3],
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
double mu2, double mv2, double X2, double Y2, double Z2)
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
double mu2, double mv2, double X2, double Y2, double Z2)
{
double mk0, mk1, mk2;
double norm;
double mk0, mk1, mk2;
double norm;
mu0 = inv_fx * mu0 - cx_fx;
mv0 = inv_fy * mv0 - cy_fy;
norm = sqrt(mu0 * mu0 + mv0 * mv0 + 1);
mk0 = 1. / norm; mu0 *= mk0; mv0 *= mk0;
mu0 = inv_fx * mu0 - cx_fx;
mv0 = inv_fy * mv0 - cy_fy;
norm = sqrt(mu0 * mu0 + mv0 * mv0 + 1);
mk0 = 1. / norm; mu0 *= mk0; mv0 *= mk0;
mu1 = inv_fx * mu1 - cx_fx;
mv1 = inv_fy * mv1 - cy_fy;
norm = sqrt(mu1 * mu1 + mv1 * mv1 + 1);
mk1 = 1. / norm; mu1 *= mk1; mv1 *= mk1;
mu1 = inv_fx * mu1 - cx_fx;
mv1 = inv_fy * mv1 - cy_fy;
norm = sqrt(mu1 * mu1 + mv1 * mv1 + 1);
mk1 = 1. / norm; mu1 *= mk1; mv1 *= mk1;
mu2 = inv_fx * mu2 - cx_fx;
mv2 = inv_fy * mv2 - cy_fy;
norm = sqrt(mu2 * mu2 + mv2 * mv2 + 1);
mk2 = 1. / norm; mu2 *= mk2; mv2 *= mk2;
mu2 = inv_fx * mu2 - cx_fx;
mv2 = inv_fy * mv2 - cy_fy;
norm = sqrt(mu2 * mu2 + mv2 * mv2 + 1);
mk2 = 1. / norm; mu2 *= mk2; mv2 *= mk2;
double distances[3];
distances[0] = sqrt( (X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2) + (Z1 - Z2) * (Z1 - Z2) );
distances[1] = sqrt( (X0 - X2) * (X0 - X2) + (Y0 - Y2) * (Y0 - Y2) + (Z0 - Z2) * (Z0 - Z2) );
distances[2] = sqrt( (X0 - X1) * (X0 - X1) + (Y0 - Y1) * (Y0 - Y1) + (Z0 - Z1) * (Z0 - Z1) );
double distances[3];
distances[0] = sqrt( (X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2) + (Z1 - Z2) * (Z1 - Z2) );
distances[1] = sqrt( (X0 - X2) * (X0 - X2) + (Y0 - Y2) * (Y0 - Y2) + (Z0 - Z2) * (Z0 - Z2) );
distances[2] = sqrt( (X0 - X1) * (X0 - X1) + (Y0 - Y1) * (Y0 - Y1) + (Z0 - Z1) * (Z0 - Z1) );
// Calculate angles
double cosines[3];
cosines[0] = mu1 * mu2 + mv1 * mv2 + mk1 * mk2;
cosines[1] = mu0 * mu2 + mv0 * mv2 + mk0 * mk2;
cosines[2] = mu0 * mu1 + mv0 * mv1 + mk0 * mk1;
// Calculate angles
double cosines[3];
cosines[0] = mu1 * mu2 + mv1 * mv2 + mk1 * mk2;
cosines[1] = mu0 * mu2 + mv0 * mv2 + mk0 * mk2;
cosines[2] = mu0 * mu1 + mv0 * mv1 + mk0 * mk1;
double lengths[4][3];
int n = solve_for_lengths(lengths, distances, cosines);
double lengths[4][3];
int n = solve_for_lengths(lengths, distances, cosines);
int nb_solutions = 0;
for(int i = 0; i < n; i++) {
double M_orig[3][3];
int nb_solutions = 0;
for(int i = 0; i < n; i++) {
double M_orig[3][3];
M_orig[0][0] = lengths[i][0] * mu0;
M_orig[0][1] = lengths[i][0] * mv0;
M_orig[0][2] = lengths[i][0] * mk0;
M_orig[0][0] = lengths[i][0] * mu0;
M_orig[0][1] = lengths[i][0] * mv0;
M_orig[0][2] = lengths[i][0] * mk0;
M_orig[1][0] = lengths[i][1] * mu1;
M_orig[1][1] = lengths[i][1] * mv1;
M_orig[1][2] = lengths[i][1] * mk1;
M_orig[1][0] = lengths[i][1] * mu1;
M_orig[1][1] = lengths[i][1] * mv1;
M_orig[1][2] = lengths[i][1] * mk1;
M_orig[2][0] = lengths[i][2] * mu2;
M_orig[2][1] = lengths[i][2] * mv2;
M_orig[2][2] = lengths[i][2] * mk2;
M_orig[2][0] = lengths[i][2] * mu2;
M_orig[2][1] = lengths[i][2] * mv2;
M_orig[2][2] = lengths[i][2] * mk2;
if (!align(M_orig, X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, R[nb_solutions], t[nb_solutions]))
continue;
if (!align(M_orig, X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, R[nb_solutions], t[nb_solutions]))
continue;
nb_solutions++;
}
nb_solutions++;
}
return nb_solutions;
return nb_solutions;
}
/// Given 3D distances between three points and cosines of 3 angles at the apex, calculates
@ -170,247 +170,247 @@ int p3p::solve(double R[4][3][3], double t[4][3],
int p3p::solve_for_lengths(double lengths[4][3], double distances[3], double cosines[3])
{
double p = cosines[0] * 2;
double q = cosines[1] * 2;
double r = cosines[2] * 2;
double p = cosines[0] * 2;
double q = cosines[1] * 2;
double r = cosines[2] * 2;
double inv_d22 = 1. / (distances[2] * distances[2]);
double a = inv_d22 * (distances[0] * distances[0]);
double b = inv_d22 * (distances[1] * distances[1]);
double inv_d22 = 1. / (distances[2] * distances[2]);
double a = inv_d22 * (distances[0] * distances[0]);
double b = inv_d22 * (distances[1] * distances[1]);
double a2 = a * a, b2 = b * b, p2 = p * p, q2 = q * q, r2 = r * r;
double pr = p * r, pqr = q * pr;
double a2 = a * a, b2 = b * b, p2 = p * p, q2 = q * q, r2 = r * r;
double pr = p * r, pqr = q * pr;
// Check reality condition (the four points should not be coplanar)
if (p2 + q2 + r2 - pqr - 1 == 0)
return 0;
// Check reality condition (the four points should not be coplanar)
if (p2 + q2 + r2 - pqr - 1 == 0)
return 0;
double ab = a * b, a_2 = 2*a;
double ab = a * b, a_2 = 2*a;
double A = -2 * b + b2 + a2 + 1 + ab*(2 - r2) - a_2;
double A = -2 * b + b2 + a2 + 1 + ab*(2 - r2) - a_2;
// Check reality condition
if (A == 0) return 0;
// Check reality condition
if (A == 0) return 0;
double a_4 = 4*a;
double a_4 = 4*a;
double B = q*(-2*(ab + a2 + 1 - b) + r2*ab + a_4) + pr*(b - b2 + ab);
double C = q2 + b2*(r2 + p2 - 2) - b*(p2 + pqr) - ab*(r2 + pqr) + (a2 - a_2)*(2 + q2) + 2;
double D = pr*(ab-b2+b) + q*((p2-2)*b + 2 * (ab - a2) + a_4 - 2);
double E = 1 + 2*(b - a - ab) + b2 - b*p2 + a2;
double B = q*(-2*(ab + a2 + 1 - b) + r2*ab + a_4) + pr*(b - b2 + ab);
double C = q2 + b2*(r2 + p2 - 2) - b*(p2 + pqr) - ab*(r2 + pqr) + (a2 - a_2)*(2 + q2) + 2;
double D = pr*(ab-b2+b) + q*((p2-2)*b + 2 * (ab - a2) + a_4 - 2);
double E = 1 + 2*(b - a - ab) + b2 - b*p2 + a2;
double temp = (p2*(a-1+b) + r2*(a-1-b) + pqr - a*pqr);
double b0 = b * temp * temp;
// Check reality condition
if (b0 == 0)
return 0;
double temp = (p2*(a-1+b) + r2*(a-1-b) + pqr - a*pqr);
double b0 = b * temp * temp;
// Check reality condition
if (b0 == 0)
return 0;
double real_roots[4];
int n = solve_deg4(A, B, C, D, E, real_roots[0], real_roots[1], real_roots[2], real_roots[3]);
double real_roots[4];
int n = solve_deg4(A, B, C, D, E, real_roots[0], real_roots[1], real_roots[2], real_roots[3]);
if (n == 0)
return 0;
if (n == 0)
return 0;
int nb_solutions = 0;
double r3 = r2*r, pr2 = p*r2, r3q = r3 * q;
double inv_b0 = 1. / b0;
int nb_solutions = 0;
double r3 = r2*r, pr2 = p*r2, r3q = r3 * q;
double inv_b0 = 1. / b0;
// For each solution of x
for(int i = 0; i < n; i++) {
double x = real_roots[i];
// For each solution of x
for(int i = 0; i < n; i++) {
double x = real_roots[i];
// Check reality condition
if (x <= 0)
continue;
// Check reality condition
if (x <= 0)
continue;
double x2 = x*x;
double x2 = x*x;
double b1 =
((1-a-b)*x2 + (q*a-q)*x + 1 - a + b) *
(((r3*(a2 + ab*(2 - r2) - a_2 + b2 - 2*b + 1)) * x +
double b1 =
((1-a-b)*x2 + (q*a-q)*x + 1 - a + b) *
(((r3*(a2 + ab*(2 - r2) - a_2 + b2 - 2*b + 1)) * x +
(r3q*(2*(b-a2) + a_4 + ab*(r2 - 2) - 2) + pr2*(1 + a2 + 2*(ab-a-b) + r2*(b - b2) + b2))) * x2 +
(r3q*(2*(b-a2) + a_4 + ab*(r2 - 2) - 2) + pr2*(1 + a2 + 2*(ab-a-b) + r2*(b - b2) + b2))) * x2 +
(r3*(q2*(1-2*a+a2) + r2*(b2-ab) - a_4 + 2*(a2 - b2) + 2) + r*p2*(b2 + 2*(ab - b - a) + 1 + a2) + pr2*q*(a_4 + 2*(b - ab - a2) - 2 - r2*b)) * x +
(r3*(q2*(1-2*a+a2) + r2*(b2-ab) - a_4 + 2*(a2 - b2) + 2) + r*p2*(b2 + 2*(ab - b - a) + 1 + a2) + pr2*q*(a_4 + 2*(b - ab - a2) - 2 - r2*b)) * x +
2*r3q*(a_2 - b - a2 + ab - 1) + pr2*(q2 - a_4 + 2*(a2 - b2) + r2*b + q2*(a2 - a_2) + 2) +
p2*(p*(2*(ab - a - b) + a2 + b2 + 1) + 2*q*r*(b + a_2 - a2 - ab - 1)));
2*r3q*(a_2 - b - a2 + ab - 1) + pr2*(q2 - a_4 + 2*(a2 - b2) + r2*b + q2*(a2 - a_2) + 2) +
p2*(p*(2*(ab - a - b) + a2 + b2 + 1) + 2*q*r*(b + a_2 - a2 - ab - 1)));
// Check reality condition
if (b1 <= 0)
continue;
// Check reality condition
if (b1 <= 0)
continue;
double y = inv_b0 * b1;
double v = x2 + y*y - x*y*r;
double y = inv_b0 * b1;
double v = x2 + y*y - x*y*r;
if (v <= 0)
continue;
if (v <= 0)
continue;
double Z = distances[2] / sqrt(v);
double X = x * Z;
double Y = y * Z;
double Z = distances[2] / sqrt(v);
double X = x * Z;
double Y = y * Z;
lengths[nb_solutions][0] = X;
lengths[nb_solutions][1] = Y;
lengths[nb_solutions][2] = Z;
lengths[nb_solutions][0] = X;
lengths[nb_solutions][1] = Y;
lengths[nb_solutions][2] = Z;
nb_solutions++;
}
nb_solutions++;
}
return nb_solutions;
return nb_solutions;
}
bool p3p::align(double M_end[3][3],
double X0, double Y0, double Z0,
double X1, double Y1, double Z1,
double X2, double Y2, double Z2,
double R[3][3], double T[3])
double X0, double Y0, double Z0,
double X1, double Y1, double Z1,
double X2, double Y2, double Z2,
double R[3][3], double T[3])
{
// Centroids:
double C_start[3], C_end[3];
for(int i = 0; i < 3; i++) C_end[i] = (M_end[0][i] + M_end[1][i] + M_end[2][i]) / 3;
C_start[0] = (X0 + X1 + X2) / 3;
C_start[1] = (Y0 + Y1 + Y2) / 3;
C_start[2] = (Z0 + Z1 + Z2) / 3;
// Centroids:
double C_start[3], C_end[3];
for(int i = 0; i < 3; i++) C_end[i] = (M_end[0][i] + M_end[1][i] + M_end[2][i]) / 3;
C_start[0] = (X0 + X1 + X2) / 3;
C_start[1] = (Y0 + Y1 + Y2) / 3;
C_start[2] = (Z0 + Z1 + Z2) / 3;
// Covariance matrix s:
double s[3 * 3];
for(int j = 0; j < 3; j++) {
s[0 * 3 + j] = (X0 * M_end[0][j] + X1 * M_end[1][j] + X2 * M_end[2][j]) / 3 - C_end[j] * C_start[0];
s[1 * 3 + j] = (Y0 * M_end[0][j] + Y1 * M_end[1][j] + Y2 * M_end[2][j]) / 3 - C_end[j] * C_start[1];
s[2 * 3 + j] = (Z0 * M_end[0][j] + Z1 * M_end[1][j] + Z2 * M_end[2][j]) / 3 - C_end[j] * C_start[2];
}
// Covariance matrix s:
double s[3 * 3];
for(int j = 0; j < 3; j++) {
s[0 * 3 + j] = (X0 * M_end[0][j] + X1 * M_end[1][j] + X2 * M_end[2][j]) / 3 - C_end[j] * C_start[0];
s[1 * 3 + j] = (Y0 * M_end[0][j] + Y1 * M_end[1][j] + Y2 * M_end[2][j]) / 3 - C_end[j] * C_start[1];
s[2 * 3 + j] = (Z0 * M_end[0][j] + Z1 * M_end[1][j] + Z2 * M_end[2][j]) / 3 - C_end[j] * C_start[2];
}
double Qs[16], evs[4], U[16];
double Qs[16], evs[4], U[16];
Qs[0 * 4 + 0] = s[0 * 3 + 0] + s[1 * 3 + 1] + s[2 * 3 + 2];
Qs[1 * 4 + 1] = s[0 * 3 + 0] - s[1 * 3 + 1] - s[2 * 3 + 2];
Qs[2 * 4 + 2] = s[1 * 3 + 1] - s[2 * 3 + 2] - s[0 * 3 + 0];
Qs[3 * 4 + 3] = s[2 * 3 + 2] - s[0 * 3 + 0] - s[1 * 3 + 1];
Qs[0 * 4 + 0] = s[0 * 3 + 0] + s[1 * 3 + 1] + s[2 * 3 + 2];
Qs[1 * 4 + 1] = s[0 * 3 + 0] - s[1 * 3 + 1] - s[2 * 3 + 2];
Qs[2 * 4 + 2] = s[1 * 3 + 1] - s[2 * 3 + 2] - s[0 * 3 + 0];
Qs[3 * 4 + 3] = s[2 * 3 + 2] - s[0 * 3 + 0] - s[1 * 3 + 1];
Qs[1 * 4 + 0] = Qs[0 * 4 + 1] = s[1 * 3 + 2] - s[2 * 3 + 1];
Qs[2 * 4 + 0] = Qs[0 * 4 + 2] = s[2 * 3 + 0] - s[0 * 3 + 2];
Qs[3 * 4 + 0] = Qs[0 * 4 + 3] = s[0 * 3 + 1] - s[1 * 3 + 0];
Qs[2 * 4 + 1] = Qs[1 * 4 + 2] = s[1 * 3 + 0] + s[0 * 3 + 1];
Qs[3 * 4 + 1] = Qs[1 * 4 + 3] = s[2 * 3 + 0] + s[0 * 3 + 2];
Qs[3 * 4 + 2] = Qs[2 * 4 + 3] = s[2 * 3 + 1] + s[1 * 3 + 2];
Qs[1 * 4 + 0] = Qs[0 * 4 + 1] = s[1 * 3 + 2] - s[2 * 3 + 1];
Qs[2 * 4 + 0] = Qs[0 * 4 + 2] = s[2 * 3 + 0] - s[0 * 3 + 2];
Qs[3 * 4 + 0] = Qs[0 * 4 + 3] = s[0 * 3 + 1] - s[1 * 3 + 0];
Qs[2 * 4 + 1] = Qs[1 * 4 + 2] = s[1 * 3 + 0] + s[0 * 3 + 1];
Qs[3 * 4 + 1] = Qs[1 * 4 + 3] = s[2 * 3 + 0] + s[0 * 3 + 2];
Qs[3 * 4 + 2] = Qs[2 * 4 + 3] = s[2 * 3 + 1] + s[1 * 3 + 2];
jacobi_4x4(Qs, evs, U);
jacobi_4x4(Qs, evs, U);
// Looking for the largest eigen value:
int i_ev = 0;
double ev_max = evs[i_ev];
for(int i = 1; i < 4; i++)
if (evs[i] > ev_max)
ev_max = evs[i_ev = i];
// Looking for the largest eigen value:
int i_ev = 0;
double ev_max = evs[i_ev];
for(int i = 1; i < 4; i++)
if (evs[i] > ev_max)
ev_max = evs[i_ev = i];
// Quaternion:
double q[4];
for(int i = 0; i < 4; i++)
q[i] = U[i * 4 + i_ev];
// Quaternion:
double q[4];
for(int i = 0; i < 4; i++)
q[i] = U[i * 4 + i_ev];
double q02 = q[0] * q[0], q12 = q[1] * q[1], q22 = q[2] * q[2], q32 = q[3] * q[3];
double q0_1 = q[0] * q[1], q0_2 = q[0] * q[2], q0_3 = q[0] * q[3];
double q1_2 = q[1] * q[2], q1_3 = q[1] * q[3];
double q2_3 = q[2] * q[3];
double q02 = q[0] * q[0], q12 = q[1] * q[1], q22 = q[2] * q[2], q32 = q[3] * q[3];
double q0_1 = q[0] * q[1], q0_2 = q[0] * q[2], q0_3 = q[0] * q[3];
double q1_2 = q[1] * q[2], q1_3 = q[1] * q[3];
double q2_3 = q[2] * q[3];
R[0][0] = q02 + q12 - q22 - q32;
R[0][1] = 2. * (q1_2 - q0_3);
R[0][2] = 2. * (q1_3 + q0_2);
R[0][0] = q02 + q12 - q22 - q32;
R[0][1] = 2. * (q1_2 - q0_3);
R[0][2] = 2. * (q1_3 + q0_2);
R[1][0] = 2. * (q1_2 + q0_3);
R[1][1] = q02 + q22 - q12 - q32;
R[1][2] = 2. * (q2_3 - q0_1);
R[1][0] = 2. * (q1_2 + q0_3);
R[1][1] = q02 + q22 - q12 - q32;
R[1][2] = 2. * (q2_3 - q0_1);
R[2][0] = 2. * (q1_3 - q0_2);
R[2][1] = 2. * (q2_3 + q0_1);
R[2][2] = q02 + q32 - q12 - q22;
R[2][0] = 2. * (q1_3 - q0_2);
R[2][1] = 2. * (q2_3 + q0_1);
R[2][2] = q02 + q32 - q12 - q22;
for(int i = 0; i < 3; i++)
T[i] = C_end[i] - (R[i][0] * C_start[0] + R[i][1] * C_start[1] + R[i][2] * C_start[2]);
for(int i = 0; i < 3; i++)
T[i] = C_end[i] - (R[i][0] * C_start[0] + R[i][1] * C_start[1] + R[i][2] * C_start[2]);
return true;
return true;
}
bool p3p::jacobi_4x4(double * A, double * D, double * U)
{
double B[4], Z[4];
double Id[16] = {1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.};
double B[4], Z[4];
double Id[16] = {1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.};
memcpy(U, Id, 16 * sizeof(double));
memcpy(U, Id, 16 * sizeof(double));
B[0] = A[0]; B[1] = A[5]; B[2] = A[10]; B[3] = A[15];
memcpy(D, B, 4 * sizeof(double));
memset(Z, 0, 4 * sizeof(double));
B[0] = A[0]; B[1] = A[5]; B[2] = A[10]; B[3] = A[15];
memcpy(D, B, 4 * sizeof(double));
memset(Z, 0, 4 * sizeof(double));
for(int iter = 0; iter < 50; iter++) {
double sum = fabs(A[1]) + fabs(A[2]) + fabs(A[3]) + fabs(A[6]) + fabs(A[7]) + fabs(A[11]);
for(int iter = 0; iter < 50; iter++) {
double sum = fabs(A[1]) + fabs(A[2]) + fabs(A[3]) + fabs(A[6]) + fabs(A[7]) + fabs(A[11]);
if (sum == 0.0)
return true;
if (sum == 0.0)
return true;
double tresh = (iter < 3) ? 0.2 * sum / 16. : 0.0;
for(int i = 0; i < 3; i++) {
double * pAij = A + 5 * i + 1;
for(int j = i + 1 ; j < 4; j++) {
double Aij = *pAij;
double eps_machine = 100.0 * fabs(Aij);
double tresh = (iter < 3) ? 0.2 * sum / 16. : 0.0;
for(int i = 0; i < 3; i++) {
double * pAij = A + 5 * i + 1;
for(int j = i + 1 ; j < 4; j++) {
double Aij = *pAij;
double eps_machine = 100.0 * fabs(Aij);
if ( iter > 3 && fabs(D[i]) + eps_machine == fabs(D[i]) && fabs(D[j]) + eps_machine == fabs(D[j]) )
*pAij = 0.0;
else if (fabs(Aij) > tresh) {
double h = D[j] - D[i], t;
if (fabs(h) + eps_machine == fabs(h))
t = Aij / h;
else {
double theta = 0.5 * h / Aij;
t = 1.0 / (fabs(theta) + sqrt(1.0 + theta * theta));
if (theta < 0.0) t = -t;
}
if ( iter > 3 && fabs(D[i]) + eps_machine == fabs(D[i]) && fabs(D[j]) + eps_machine == fabs(D[j]) )
*pAij = 0.0;
else if (fabs(Aij) > tresh) {
double hh = D[j] - D[i], t;
if (fabs(hh) + eps_machine == fabs(hh))
t = Aij / hh;
else {
double theta = 0.5 * hh / Aij;
t = 1.0 / (fabs(theta) + sqrt(1.0 + theta * theta));
if (theta < 0.0) t = -t;
}
h = t * Aij;
Z[i] -= h;
Z[j] += h;
D[i] -= h;
D[j] += h;
*pAij = 0.0;
hh = t * Aij;
Z[i] -= hh;
Z[j] += hh;
D[i] -= hh;
D[j] += hh;
*pAij = 0.0;
double c = 1.0 / sqrt(1 + t * t);
double s = t * c;
double tau = s / (1.0 + c);
for(int k = 0; k <= i - 1; k++) {
double g = A[k * 4 + i], h = A[k * 4 + j];
A[k * 4 + i] = g - s * (h + g * tau);
A[k * 4 + j] = h + s * (g - h * tau);
}
for(int k = i + 1; k <= j - 1; k++) {
double g = A[i * 4 + k], h = A[k * 4 + j];
A[i * 4 + k] = g - s * (h + g * tau);
A[k * 4 + j] = h + s * (g - h * tau);
}
for(int k = j + 1; k < 4; k++) {
double g = A[i * 4 + k], h = A[j * 4 + k];
A[i * 4 + k] = g - s * (h + g * tau);
A[j * 4 + k] = h + s * (g - h * tau);
}
for(int k = 0; k < 4; k++) {
double g = U[k * 4 + i], h = U[k * 4 + j];
U[k * 4 + i] = g - s * (h + g * tau);
U[k * 4 + j] = h + s * (g - h * tau);
}
}
pAij++;
}
}
double c = 1.0 / sqrt(1 + t * t);
double s = t * c;
double tau = s / (1.0 + c);
for(int k = 0; k <= i - 1; k++) {
double g = A[k * 4 + i], h = A[k * 4 + j];
A[k * 4 + i] = g - s * (h + g * tau);
A[k * 4 + j] = h + s * (g - h * tau);
}
for(int k = i + 1; k <= j - 1; k++) {
double g = A[i * 4 + k], h = A[k * 4 + j];
A[i * 4 + k] = g - s * (h + g * tau);
A[k * 4 + j] = h + s * (g - h * tau);
}
for(int k = j + 1; k < 4; k++) {
double g = A[i * 4 + k], h = A[j * 4 + k];
A[i * 4 + k] = g - s * (h + g * tau);
A[j * 4 + k] = h + s * (g - h * tau);
}
for(int k = 0; k < 4; k++) {
double g = U[k * 4 + i], h = U[k * 4 + j];
U[k * 4 + i] = g - s * (h + g * tau);
U[k * 4 + j] = h + s * (g - h * tau);
}
}
pAij++;
}
}
for(int i = 0; i < 4; i++) B[i] += Z[i];
memcpy(D, B, 4 * sizeof(double));
memset(Z, 0, 4 * sizeof(double));
}
for(int i = 0; i < 4; i++) B[i] += Z[i];
memcpy(D, B, 4 * sizeof(double));
memset(Z, 0, 4 * sizeof(double));
}
return false;
return false;
}

View File

@ -253,10 +253,10 @@ namespace cv
}
}
}
PnPSolver(const Mat& objectPoints, const Mat& imagePoints, const Parameters& parameters,
Mat& rvec, Mat& tvec, vector<int>& inliers):
objectPoints(objectPoints), imagePoints(imagePoints), parameters(parameters),
rvec(rvec), tvec(tvec), inliers(inliers)
PnPSolver(const Mat& _objectPoints, const Mat& _imagePoints, const Parameters& _parameters,
Mat& _rvec, Mat& _tvec, vector<int>& _inliers):
objectPoints(_objectPoints), imagePoints(_imagePoints), parameters(_parameters),
rvec(_rvec), tvec(_tvec), inliers(_inliers)
{
rvec.copyTo(initRvec);
tvec.copyTo(initTvec);

View File

@ -336,7 +336,7 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
short* costptr = cost.data ? (short*)cost.data + lofs + x : &costbuf;
int x0 = x - wsz2 - 1, x1 = x + wsz2;
const uchar* cbuf_sub = cbuf0 + ((x0 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
uchar* cbuf = cbuf0 + ((x1 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
cbuf = cbuf0 + ((x1 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
hsad = hsad0 - dy0*ndisp;
lptr_sub = lptr0 + MIN(MAX(x0, -lofs), width-1-lofs) - dy0*sstep;
lptr = lptr0 + MIN(MAX(x1, -lofs), width-1-lofs) - dy0*sstep;
@ -463,7 +463,8 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
int thresh = minsad + ((minsad * uniquenessRatio) >> 8);
__m128i thresh8 = _mm_set1_epi16((short)(thresh + 1));
__m128i d1 = _mm_set1_epi16((short)(mind-1)), d2 = _mm_set1_epi16((short)(mind+1));
__m128i dd_16 = _mm_add_epi16(dd_8, dd_8), d8 = _mm_sub_epi16(d0_8, dd_16);
__m128i dd_16 = _mm_add_epi16(dd_8, dd_8);
d8 = _mm_sub_epi16(d0_8, dd_16);
for( d = 0; d < ndisp; d += 16 )
{
@ -492,7 +493,8 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
if( 0 < mind && mind < ndisp - 1 )
{
int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind] + std::abs(p - n);
int p = sad[mind+1], n = sad[mind-1];
d = p + n - 2*sad[mind] + std::abs(p - n);
dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) >> 4);
}
else
@ -583,7 +585,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
int* costptr = cost.data ? (int*)cost.data + lofs + x : &costbuf;
int x0 = x - wsz2 - 1, x1 = x + wsz2;
const uchar* cbuf_sub = cbuf0 + ((x0 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
uchar* cbuf = cbuf0 + ((x1 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
cbuf = cbuf0 + ((x1 + wsz2 + 1) % (wsz + 1))*cstep - dy0*ndisp;
hsad = hsad0 - dy0*ndisp;
lptr_sub = lptr0 + MIN(MAX(x0, -lofs), width-1-lofs) - dy0*sstep;
lptr = lptr0 + MIN(MAX(x1, -lofs), width-1-lofs) - dy0*sstep;
@ -662,7 +664,8 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
{
sad[-1] = sad[1];
sad[ndisp] = sad[ndisp-2];
int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind] + std::abs(p - n);
int p = sad[mind+1], n = sad[mind-1];
d = p + n - 2*sad[mind] + std::abs(p - n);
dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) >> 4);
costptr[y*coststep] = sad[mind];
}

View File

@ -773,11 +773,11 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
if( d < D )
continue;
d = bestDisp;
int x2 = x + minX1 - d - minD;
if( disp2cost[x2] > minS )
int _x2 = x + minX1 - d - minD;
if( disp2cost[_x2] > minS )
{
disp2cost[x2] = (CostType)minS;
disp2ptr[x2] = (DispType)(d + minD);
disp2cost[_x2] = (CostType)minS;
disp2ptr[_x2] = (DispType)(d + minD);
}
if( 0 < d && d < D-1 )
@ -798,11 +798,11 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
// we round the computed disparity both towards -inf and +inf and check
// if either of the corresponding disparities in disp2 is consistent.
// This is to give the computed disparity a chance to look valid if it is.
int d = disp1ptr[x];
if( d == INVALID_DISP_SCALED )
int d1 = disp1ptr[x];
if( d1 == INVALID_DISP_SCALED )
continue;
int _d = d >> DISP_SHIFT;
int d_ = (d + DISP_SCALE-1) >> DISP_SHIFT;
int _d = d1 >> DISP_SHIFT;
int d_ = (d1 + DISP_SCALE-1) >> DISP_SHIFT;
int _x = x - _d, x_ = x - d_;
if( 0 <= _x && _x < width && disp2ptr[_x] >= minD && std::abs(disp2ptr[_x] - _d) > disp12MaxDiff &&
0 <= x_ && x_ < width && disp2ptr[x_] >= minD && std::abs(disp2ptr[x_] - d_) > disp12MaxDiff )
@ -890,9 +890,9 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
for( j = 0; j < width; j++ )
{
if( ds[j] != newVal ) // not a bad disparity
if( ds[j] != newVal ) // not a bad disparity
{
if( ls[j] ) // has a label, check for bad label
if( ls[j] ) // has a label, check for bad label
{
if( rtype[ls[j]] ) // small region, zero out disparity
ds[j] = (short)newVal;
@ -900,10 +900,10 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
// no label, assign and propagate
else
{
Point2s* ws = wbuf; // initialize wavefront
Point2s p((short)j, (short)i); // current pixel
curlabel++; // next label
int count = 0; // current region size
Point2s* ws = wbuf; // initialize wavefront
Point2s p((short)j, (short)i); // current pixel
curlabel++; // next label
int count = 0; // current region size
ls[j] = curlabel;
// wavefront propagation
@ -945,13 +945,13 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
}
// assign label type
if( count <= maxSpeckleSize ) // speckle region
if( count <= maxSpeckleSize ) // speckle region
{
rtype[ls[j]] = 1; // small region label
rtype[ls[j]] = 1; // small region label
ds[j] = (short)newVal;
}
else
rtype[ls[j]] = 0; // large region label
rtype[ls[j]] = 0; // large region label
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -221,19 +221,19 @@ protected:
}
}
double reprojectErrorWithoutIntrinsics(const vector<Point3f>& cb3d, const vector<Mat>& rvecs_exp, const vector<Mat>& tvecs_exp,
double reprojectErrorWithoutIntrinsics(const vector<Point3f>& cb3d, const vector<Mat>& _rvecs_exp, const vector<Mat>& _tvecs_exp,
const vector<Mat>& rvecs_est, const vector<Mat>& tvecs_est)
{
const static Mat eye33 = Mat::eye(3, 3, CV_64F);
const static Mat zero15 = Mat::zeros(1, 5, CV_64F);
Mat chessboard3D(cb3d);
Mat _chessboard3D(cb3d);
vector<Point2f> uv_exp, uv_est;
double res = 0;
for(size_t i = 0; i < rvecs_exp.size(); ++i)
{
projectPoints(chessboard3D, rvecs_exp[i], tvecs_exp[i], eye33, zero15, uv_exp);
projectPoints(chessboard3D, rvecs_est[i], tvecs_est[i], eye33, zero15, uv_est);
projectPoints(_chessboard3D, _rvecs_exp[i], _tvecs_exp[i], eye33, zero15, uv_exp);
projectPoints(_chessboard3D, rvecs_est[i], tvecs_est[i], eye33, zero15, uv_est);
for(size_t j = 0; j < cb3d.size(); ++j)
res += norm(uv_exp[i] - uv_est[i]);
}

View File

@ -137,8 +137,7 @@ const double precise_success_error_level = 2;
/* ///////////////////// chess_corner_test ///////////////////////// */
void CV_ChessboardDetectorTest::run( int /*start_from */)
{
cvtest::TS& ts = *this->ts;
ts.set_failed_test_info( cvtest::TS::OK );
ts->set_failed_test_info( cvtest::TS::OK );
/*if (!checkByGenerator())
return;*/
@ -146,19 +145,19 @@ void CV_ChessboardDetectorTest::run( int /*start_from */)
{
case CHESSBOARD:
checkByGenerator();
if (ts.get_err_code() != cvtest::TS::OK)
if (ts->get_err_code() != cvtest::TS::OK)
{
break;
}
run_batch("negative_list.dat");
if (ts.get_err_code() != cvtest::TS::OK)
if (ts->get_err_code() != cvtest::TS::OK)
{
break;
}
run_batch("chessboard_list.dat");
if (ts.get_err_code() != cvtest::TS::OK)
if (ts->get_err_code() != cvtest::TS::OK)
{
break;
}
@ -176,9 +175,7 @@ void CV_ChessboardDetectorTest::run( int /*start_from */)
void CV_ChessboardDetectorTest::run_batch( const string& filename )
{
cvtest::TS& ts = *this->ts;
ts.printf(cvtest::TS::LOG, "\nRunning batch %s\n", filename.c_str());
ts->printf(cvtest::TS::LOG, "\nRunning batch %s\n", filename.c_str());
//#define WRITE_POINTS 1
#ifndef WRITE_POINTS
double max_rough_error = 0, max_precise_error = 0;
@ -187,13 +184,13 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
switch( pattern )
{
case CHESSBOARD:
folder = string(ts.get_data_path()) + "cameracalibration/";
folder = string(ts->get_data_path()) + "cameracalibration/";
break;
case CIRCLES_GRID:
folder = string(ts.get_data_path()) + "cameracalibration/circles/";
folder = string(ts->get_data_path()) + "cameracalibration/circles/";
break;
case ASYMMETRIC_CIRCLES_GRID:
folder = string(ts.get_data_path()) + "cameracalibration/asymmetric_circles/";
folder = string(ts->get_data_path()) + "cameracalibration/asymmetric_circles/";
break;
}
@ -202,10 +199,10 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
if( !fs.isOpened() || board_list.empty() || !board_list.isSeq() || board_list.size() % 2 != 0 )
{
ts.printf( cvtest::TS::LOG, "%s can not be readed or is not valid\n", (folder + filename).c_str() );
ts.printf( cvtest::TS::LOG, "fs.isOpened=%d, board_list.empty=%d, board_list.isSeq=%d,board_list.size()%2=%d\n",
ts->printf( cvtest::TS::LOG, "%s can not be readed or is not valid\n", (folder + filename).c_str() );
ts->printf( cvtest::TS::LOG, "fs.isOpened=%d, board_list.empty=%d, board_list.isSeq=%d,board_list.size()%2=%d\n",
fs.isOpened(), (int)board_list.empty(), board_list.isSeq(), board_list.size()%2);
ts.set_failed_test_info( cvtest::TS::FAIL_MISSING_TEST_DATA );
ts->set_failed_test_info( cvtest::TS::FAIL_MISSING_TEST_DATA );
return;
}
@ -216,7 +213,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
for(int idx = 0; idx < max_idx; ++idx )
{
ts.update_context( this, idx, true );
ts->update_context( this, idx, true );
/* read the image */
string img_file = board_list[idx * 2];
@ -224,19 +221,19 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
if( gray.empty() )
{
ts.printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", img_file.c_str() );
ts.set_failed_test_info( cvtest::TS::FAIL_MISSING_TEST_DATA );
ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", img_file.c_str() );
ts->set_failed_test_info( cvtest::TS::FAIL_MISSING_TEST_DATA );
return;
}
string filename = folder + (string)board_list[idx * 2 + 1];
string _filename = folder + (string)board_list[idx * 2 + 1];
bool doesContatinChessboard;
Mat expected;
{
FileStorage fs(filename, FileStorage::READ);
fs["corners"] >> expected;
fs["isFound"] >> doesContatinChessboard;
fs.release();
FileStorage fs1(_filename, FileStorage::READ);
fs1["corners"] >> expected;
fs1["isFound"] >> doesContatinChessboard;
fs1.release();
}
size_t count_exp = static_cast<size_t>(expected.cols * expected.rows);
Size pattern_size = expected.size();
@ -259,8 +256,8 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
if( result ^ doesContatinChessboard || v.size() != count_exp )
{
ts.printf( cvtest::TS::LOG, "chessboard is detected incorrectly in %s\n", img_file.c_str() );
ts.set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
ts->printf( cvtest::TS::LOG, "chessboard is detected incorrectly in %s\n", img_file.c_str() );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
return;
}
@ -291,19 +288,19 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
#if 1
if( err > precise_success_error_level )
{
ts.printf( cvtest::TS::LOG, "Image %s: bad accuracy of adjusted corners %f\n", img_file.c_str(), err );
ts.set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
ts->printf( cvtest::TS::LOG, "Image %s: bad accuracy of adjusted corners %f\n", img_file.c_str(), err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}
#endif
ts.printf(cvtest::TS::LOG, "Error on %s is %f\n", img_file.c_str(), err);
ts->printf(cvtest::TS::LOG, "Error on %s is %f\n", img_file.c_str(), err);
max_precise_error = MAX( max_precise_error, err );
#endif
}
#ifdef WRITE_POINTS
Mat mat_v(pattern_size, CV_32FC2, (void*)&v[0]);
FileStorage fs(filename, FileStorage::WRITE);
FileStorage fs(_filename, FileStorage::WRITE);
fs << "isFound" << result;
fs << "corners" << mat_v;
fs.release();
@ -312,7 +309,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
}
sum_error /= count;
ts.printf(cvtest::TS::LOG, "Average error is %f\n", sum_error);
ts->printf(cvtest::TS::LOG, "Average error is %f\n", sum_error);
}
double calcErrorMinError(const Size& cornSz, const vector<Point2f>& corners_found, const vector<Point2f>& corners_generated)

View File

@ -139,8 +139,7 @@ protected:
void run(int)
{
cvtest::TS& ts = *this->ts;
ts.set_failed_test_info(cvtest::TS::OK);
ts->set_failed_test_info(cvtest::TS::OK);
Mat_<double> rvec1(3, 1), tvec1(3, 1), rvec2(3, 1), tvec2(3, 1);
@ -164,7 +163,7 @@ protected:
const double thres = 1e-5;
if (norm(rvec3_exp, rvec3) > thres || norm(tvec3_exp, tvec3) > thres)
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
const double eps = 1e-3;
Differential diff(eps, rvec1, tvec1, rvec2, tvec2);
@ -179,8 +178,8 @@ protected:
if (norm(dr3_dr1, dr3dr1) > thres || norm(dt3_dr1, dt3dr1) > thres)
{
ts.printf( cvtest::TS::LOG, "Invalid derivates by r1\n" );
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->printf( cvtest::TS::LOG, "Invalid derivates by r1\n" );
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
}
Mat_<double> dr3_dr2, dt3_dr2;
@ -188,8 +187,8 @@ protected:
if (norm(dr3_dr2, dr3dr2) > thres || norm(dt3_dr2, dt3dr2) > thres)
{
ts.printf( cvtest::TS::LOG, "Invalid derivates by r2\n" );
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->printf( cvtest::TS::LOG, "Invalid derivates by r2\n" );
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
}
Mat_<double> dr3_dt1, dt3_dt1;
@ -197,8 +196,8 @@ protected:
if (norm(dr3_dt1, dr3dt1) > thres || norm(dt3_dt1, dt3dt1) > thres)
{
ts.printf( cvtest::TS::LOG, "Invalid derivates by t1\n" );
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->printf( cvtest::TS::LOG, "Invalid derivates by t1\n" );
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
}
Mat_<double> dr3_dt2, dt3_dt2;
@ -206,8 +205,8 @@ protected:
if (norm(dr3_dt2, dr3dt2) > thres || norm(dt3_dt2, dt3dt2) > thres)
{
ts.printf( cvtest::TS::LOG, "Invalid derivates by t2\n" );
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->printf( cvtest::TS::LOG, "Invalid derivates by t2\n" );
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
}
}
};

View File

@ -86,20 +86,20 @@ protected:
double sigma;
private:
float max_diff, max_2diff;
bool check_matrix_size(const cv::Mat& H);
bool check_matrix_diff(const cv::Mat& original, const cv::Mat& found, const int norm_type, double &diff);
float max_diff, max_2diff;
bool check_matrix_size(const cv::Mat& H);
bool check_matrix_diff(const cv::Mat& original, const cv::Mat& found, const int norm_type, double &diff);
int check_ransac_mask_1(const Mat& src, const Mat& mask);
int check_ransac_mask_2(const Mat& original_mask, const Mat& found_mask);
int check_ransac_mask_2(const Mat& original_mask, const Mat& found_mask);
void print_information_1(int j, int N, int method, const Mat& H);
void print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff);
void print_information_3(int j, int N, const Mat& mask);
void print_information_4(int method, int j, int N, int k, int l, double diff);
void print_information_5(int method, int j, int N, int l, double diff);
void print_information_6(int j, int N, int k, double diff, bool value);
void print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value);
void print_information_8(int j, int N, int k, int l, double diff);
void print_information_1(int j, int N, int method, const Mat& H);
void print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff);
void print_information_3(int j, int N, const Mat& mask);
void print_information_4(int method, int j, int N, int k, int l, double diff);
void print_information_5(int method, int j, int N, int l, double diff);
void print_information_6(int j, int N, int k, double diff, bool value);
void print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value);
void print_information_8(int j, int N, int k, int l, double diff);
};
CV_HomographyTest::CV_HomographyTest() : max_diff(1e-2f), max_2diff(2e-2f)
@ -138,25 +138,25 @@ int CV_HomographyTest::check_ransac_mask_2(const Mat& original_mask, const Mat&
return 0;
}
void CV_HomographyTest::print_information_1(int j, int N, int method, const Mat& H)
void CV_HomographyTest::print_information_1(int j, int N, int _method, const Mat& H)
{
cout << endl; cout << "Checking for homography matrix sizes..." << endl; cout << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << endl; cout << endl;
cout << "Method: "; if (method == 0) cout << 0; else if (method == 8) cout << "RANSAC"; else cout << "LMEDS"; cout << endl;
cout << "Method: "; if (_method == 0) cout << 0; else if (_method == 8) cout << "RANSAC"; else cout << "LMEDS"; cout << endl;
cout << "Homography matrix:" << endl; cout << endl;
cout << H << endl; cout << endl;
cout << "Number of rows: " << H.rows << " Number of cols: " << H.cols << endl; cout << endl;
}
void CV_HomographyTest::print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff)
void CV_HomographyTest::print_information_2(int j, int N, int _method, const Mat& H, const Mat& H_res, int k, double diff)
{
cout << endl; cout << "Checking for accuracy of homography matrix computing..." << endl; cout << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << endl; cout << endl;
cout << "Method: "; if (method == 0) cout << 0; else if (method == 8) cout << "RANSAC"; else cout << "LMEDS"; cout << endl;
cout << "Method: "; if (_method == 0) cout << 0; else if (_method == 8) cout << "RANSAC"; else cout << "LMEDS"; cout << endl;
cout << "Original matrix:" << endl; cout << endl;
cout << H << endl; cout << endl;
cout << "Found matrix:" << endl; cout << endl;
@ -178,10 +178,10 @@ void CV_HomographyTest::print_information_3(int j, int N, const Mat& mask)
cout << "Number of rows: " << mask.rows << " Number of cols: " << mask.cols << endl; cout << endl;
}
void CV_HomographyTest::print_information_4(int method, int j, int N, int k, int l, double diff)
void CV_HomographyTest::print_information_4(int _method, int j, int N, int k, int l, double diff)
{
cout << endl; cout << "Checking for accuracy of reprojection error computing..." << endl; cout << endl;
cout << "Method: "; if (method == 0) cout << 0 << endl; else cout << "CV_LMEDS" << endl;
cout << "Method: "; if (_method == 0) cout << 0 << endl; else cout << "CV_LMEDS" << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Sigma of normal noise: " << sigma << endl;
@ -192,10 +192,10 @@ void CV_HomographyTest::print_information_4(int method, int j, int N, int k, int
cout << "Maxumum allowed difference: " << max_2diff << endl; cout << endl;
}
void CV_HomographyTest::print_information_5(int method, int j, int N, int l, double diff)
void CV_HomographyTest::print_information_5(int _method, int j, int N, int l, double diff)
{
cout << endl; cout << "Checking for accuracy of reprojection error computing..." << endl; cout << endl;
cout << "Method: "; if (method == 0) cout << 0 << endl; else cout << "CV_LMEDS" << endl;
cout << "Method: "; if (_method == 0) cout << 0 << endl; else cout << "CV_LMEDS" << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Sigma of normal noise: " << sigma << endl;
@ -412,7 +412,7 @@ void CV_HomographyTest::run(int)
{
case 0:
case CV_LMEDS:
{
{
Mat H_res_64 [4] = { cv::findHomography(src_mat_2f, dst_mat_2f),
cv::findHomography(src_mat_2f, dst_vec),
cv::findHomography(src_vec, dst_mat_2f),
@ -465,7 +465,7 @@ void CV_HomographyTest::run(int)
}
continue;
}
}
case CV_RANSAC:
{
cv::Mat mask_res [4];

View File

@ -106,7 +106,7 @@ protected:
}
}
virtual bool runTest(RNG& rng, int mode, int method, const vector<Point3f>& points, const double* eps, double& maxError)
virtual bool runTest(RNG& rng, int mode, int method, const vector<Point3f>& points, const double* epsilon, double& maxError)
{
Mat rvec, tvec;
vector<int> inliers;
@ -136,7 +136,7 @@ protected:
bool isTestSuccess = inliers.size() >= points.size()*0.95;
double rvecDiff = norm(rvec-trueRvec), tvecDiff = norm(tvec-trueTvec);
isTestSuccess = isTestSuccess && rvecDiff < eps[method] && tvecDiff < eps[method];
isTestSuccess = isTestSuccess && rvecDiff < epsilon[method] && tvecDiff < epsilon[method];
double error = rvecDiff > tvecDiff ? rvecDiff : tvecDiff;
//cout << error << " " << inliers.size() << " " << eps[method] << endl;
if (error > maxError)
@ -147,8 +147,7 @@ protected:
void run(int)
{
cvtest::TS& ts = *this->ts;
ts.set_failed_test_info(cvtest::TS::OK);
ts->set_failed_test_info(cvtest::TS::OK);
vector<Point3f> points;
const int pointsCount = 500;
@ -157,7 +156,7 @@ protected:
const int methodsCount = 3;
RNG rng = ts.get_rng();
RNG rng = ts->get_rng();
for (int mode = 0; mode < 2; mode++)
@ -174,9 +173,9 @@ protected:
//cout << maxError << " " << successfulTestsCount << endl;
if (successfulTestsCount < 0.7*totalTestsCount)
{
ts.printf( cvtest::TS::LOG, "Invalid accuracy for method %d, failed %d tests from %d, maximum error equals %f, distortion mode equals %d\n",
ts->printf( cvtest::TS::LOG, "Invalid accuracy for method %d, failed %d tests from %d, maximum error equals %f, distortion mode equals %d\n",
method, totalTestsCount - successfulTestsCount, totalTestsCount, maxError, mode);
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
}
}
}
@ -198,7 +197,7 @@ public:
~CV_solvePnP_Test() {}
protected:
virtual bool runTest(RNG& rng, int mode, int method, const vector<Point3f>& points, const double* eps, double& maxError)
virtual bool runTest(RNG& rng, int mode, int method, const vector<Point3f>& points, const double* epsilon, double& maxError)
{
Mat rvec, tvec;
Mat trueRvec, trueTvec;
@ -226,7 +225,7 @@ protected:
false, method);
double rvecDiff = norm(rvec-trueRvec), tvecDiff = norm(tvec-trueTvec);
bool isTestSuccess = rvecDiff < eps[method] && tvecDiff < eps[method];
bool isTestSuccess = rvecDiff < epsilon[method] && tvecDiff < epsilon[method];
double error = rvecDiff > tvecDiff ? rvecDiff : tvecDiff;
if (error > maxError)

View File

@ -593,11 +593,11 @@ int CV_StereoMatchingTest::readDatasetsParams( FileStorage& fs )
assert(fn.isSeq());
for( int i = 0; i < (int)fn.size(); i+=3 )
{
string name = fn[i];
string _name = fn[i];
DatasetParams params;
string sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str());
string uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str());
datasetsParams[name] = params;
datasetsParams[_name] = params;
}
return cvtest::TS::OK;
}

View File

@ -585,34 +585,34 @@ namespace cv
//! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, Mat& disp);
CV_PROP_RW int levels;
CV_PROP_RW double pyrScale;
CV_PROP_RW int nIt;
CV_PROP_RW int minDisp;
CV_PROP_RW int maxDisp;
CV_PROP_RW int poly_n;
CV_PROP_RW double poly_sigma;
CV_PROP_RW float fi;
CV_PROP_RW float lambda;
CV_PROP_RW int penalization;
CV_PROP_RW int cycle;
CV_PROP_RW int flags;
CV_PROP_RW int levels;
CV_PROP_RW double pyrScale;
CV_PROP_RW int nIt;
CV_PROP_RW int minDisp;
CV_PROP_RW int maxDisp;
CV_PROP_RW int poly_n;
CV_PROP_RW double poly_sigma;
CV_PROP_RW float fi;
CV_PROP_RW float lambda;
CV_PROP_RW int penalization;
CV_PROP_RW int cycle;
CV_PROP_RW int flags;
private:
void autoParams();
void FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level);
void FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level);
void VCycle_MyFAS(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
void VariationalSolver(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
};
CV_EXPORTS void polyfit(const Mat& srcx, const Mat& srcy, Mat& dst, int order);
class CV_EXPORTS Directory
class CV_EXPORTS Directory
{
public:
static std::vector<std::string> GetListFiles ( const std::string& path, const std::string & exten = "*", bool addPath = true );
static std::vector<std::string> GetListFilesR ( const std::string& path, const std::string & exten = "*", bool addPath = true );
static std::vector<std::string> GetListFolders( const std::string& path, const std::string & exten = "*", bool addPath = true );
public:
static std::vector<std::string> GetListFiles ( const std::string& path, const std::string & exten = "*", bool addPath = true );
static std::vector<std::string> GetListFilesR ( const std::string& path, const std::string & exten = "*", bool addPath = true );
static std::vector<std::string> GetListFolders( const std::string& path, const std::string & exten = "*", bool addPath = true );
};
/*

View File

@ -86,10 +86,10 @@ struct CV_EXPORTS CvMeanShiftTrackerParams
struct CV_EXPORTS CvFeatureTrackerParams
{
enum { SIFT = 0, SURF = 1, OPTICAL_FLOW = 2 };
CvFeatureTrackerParams(int feature_type = 0, int window_size = 0)
CvFeatureTrackerParams(int featureType = 0, int windowSize = 0)
{
feature_type = 0;
window_size = 0;
featureType = 0;
windowSize = 0;
}
int feature_type; // Feature type to use

View File

@ -67,15 +67,15 @@ LevMarqSparse::LevMarqSparse(int npoints, // number of points
// 1 - point is visible for the camera, 0 - invisible
Mat& P0, // starting vector of parameters, first cameras then points
Mat& X_, // measurements, in order of visibility. non visible cases are skipped
TermCriteria criteria, // termination criteria
TermCriteria _criteria, // termination criteria
// callback for estimation of Jacobian matrices
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
void (CV_CDECL * _fjac)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& A, Mat& B, void* data),
// callback for estimation of backprojection errors
void (CV_CDECL * func)(int i, int j, Mat& point_params,
void (CV_CDECL * _func)(int i, int j, Mat& point_params,
Mat& cam_params, Mat& estim, void* data),
void* data, // user-specific data passed to the callbacks
void* _data, // user-specific data passed to the callbacks
BundleAdjustCallback _cb, void* _user_data
) {
Vis_index = X = prevP = P = deltaP = err = JtJ_diag = S = hX = NULL;
@ -86,7 +86,7 @@ LevMarqSparse::LevMarqSparse(int npoints, // number of points
user_data = _user_data;
run(npoints, ncameras, nPointParams, nCameraParams, nErrParams, visibility,
P0, X_, criteria, fjac, func, data);
P0, X_, _criteria, _fjac, _func, _data);
}
void LevMarqSparse::clear() {
@ -443,9 +443,11 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
} //U_j and ea_j computed for all j
// if (!(iters%100))
int nviz = X->rows / num_err_param;
double e2 = prevErrNorm*prevErrNorm, e2n = e2 / nviz;
std::cerr<<"Iteration: "<<iters<<", normError: "<<e2<<" ("<<e2n<<")"<<std::endl;
{
int nviz = X->rows / num_err_param;
double e2 = prevErrNorm*prevErrNorm, e2n = e2 / nviz;
std::cerr<<"Iteration: "<<iters<<", normError: "<<e2<<" ("<<e2n<<")"<<std::endl;
}
if (cb)
cb(iters, prevErrNorm, user_data);
//compute V_i and eb_i
@ -676,10 +678,12 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
errNorm > prevErrNorm ) { //step was not accepted
//increase lambda and reject change
lambda *= 10;
int nviz = X->rows / num_err_param;
double e2 = errNorm*errNorm, e2_prev = prevErrNorm*prevErrNorm;
double e2n = e2/nviz, e2n_prev = e2_prev/nviz;
std::cerr<<"move failed: lambda = "<<lambda<<", e2 = "<<e2<<" ("<<e2n<<") > "<<e2_prev<<" ("<<e2n_prev<<")"<<std::endl;
{
int nviz = X->rows / num_err_param;
double e2 = errNorm*errNorm, e2_prev = prevErrNorm*prevErrNorm;
double e2n = e2/nviz, e2n_prev = e2_prev/nviz;
std::cerr<<"move failed: lambda = "<<lambda<<", e2 = "<<e2<<" ("<<e2n<<") > "<<e2_prev<<" ("<<e2n_prev<<")"<<std::endl;
}
//restore diagonal from backup
{
@ -886,9 +890,9 @@ static void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, C
double c[4] = { g+2*p1*y_strike+4*p2*x_strike, 2*p1*x_strike,
2*p2*y_strike, g+2*p2*x_strike + 4*p1*y_strike };
CvMat coeffmat = cvMat(2,2,CV_64F, c );
CvMat coeffmat2 = cvMat(2,2,CV_64F, c );
cvMatMul(&coeffmat, dstrike_dbig, dstrike2_dbig );
cvMatMul(&coeffmat2, dstrike_dbig, dstrike2_dbig );
cvGEMM( &strike, dg_dbig, 1, NULL, 0, tmp, CV_GEMM_A_T );
cvAdd( dstrike2_dbig, tmp, dstrike2_dbig );

View File

@ -180,13 +180,13 @@ void BasicRetinaFilter::setLPfilterParameters(const float beta, const float tau,
}
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
float _a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[1+tableOffset]=(1.0f-_a)*(1.0f-_a)*(1.0f-_a)*(1.0f-_a)/(1.0f+_beta);
float a = _filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[1+tableOffset]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
_filteringCoeficientsTable[2+tableOffset] =tau;
//std::cout<<"BasicRetinaFilter::normal:"<<(1.0-_a)*(1.0-_a)*(1.0-_a)*(1.0-_a)/(1.0+_beta)<<" -> old:"<<(1-_a)*(1-_a)*(1-_a)*(1-_a)/(1+_beta)<<std::endl;
//std::cout<<"BasicRetinaFilter::normal:"<<(1.0-a)*(1.0-a)*(1.0-a)*(1.0-a)/(1.0+_beta)<<" -> old:"<<(1-a)*(1-a)*(1-a)*(1-a)/(1+_beta)<<std::endl;
//std::cout<<"BasicRetinaFilter::_a="<<_a<<", gain="<<_filteringCoeficientsTable[1+tableOffset]<<", tau="<<tau<<std::endl;
//std::cout<<"BasicRetinaFilter::a="<<a<<", gain="<<_filteringCoeficientsTable[1+tableOffset]<<", tau="<<tau<<std::endl;
}
void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const float beta, const float tau, const float alpha0, const unsigned int filterIndex)
@ -210,8 +210,8 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa
float _alpha=0.8f;
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
float _a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[tableOffset+1]=(1.0f-_a)*(1.0f-_a)*(1.0f-_a)*(1.0f-_a)/(1.0f+_beta);
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
_filteringCoeficientsTable[tableOffset+2] =tau;
float commonFactor=alpha0/(float)sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0f);
@ -266,8 +266,8 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CustomAccuracy(const float
}
unsigned int tableOffset=filterIndex*3;
float _temp = (1.0f+_beta)/(2.0f*_mu*_alpha);
float _a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[tableOffset+1]=(1.0f-_a)*(1.0f-_a)*(1.0f-_a)*(1.0f-_a)/(1.0f+_beta);
float a=_filteringCoeficientsTable[tableOffset] = 1.0f + _temp - (float)sqrt( (1.0f+_temp)*(1.0f+_temp) - 1.0f);
_filteringCoeficientsTable[tableOffset+1]=(1.0f-a)*(1.0f-a)*(1.0f-a)*(1.0f-a)/(1.0f+_beta);
_filteringCoeficientsTable[tableOffset+2] =tau;
//memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels());

View File

@ -68,10 +68,10 @@ void CvMeanShiftTracker::newTrackingWindow(Mat image, Rect selection)
mixChannels(&hsv, 1, &hue, 1, channels, 2);
Mat roi(hue, selection);
Mat maskroi(mask, selection);
Mat mskroi(mask, selection);
int ch[] = {0, 1};
int chsize[] = {32, 32};
calcHist(&roi, 1, ch, maskroi, hist, 1, chsize, ranges);
calcHist(&roi, 1, ch, mskroi, hist, 1, chsize, ranges);
normalize(hist, hist, 0, 255, CV_MINMAX);
prev_trackwindow = selection;

View File

@ -208,11 +208,11 @@ public:
//
// radius, neighbors are used in the local binary patterns creation.
// grid_x, grid_y control the grid size of the spatial histograms.
LBPH(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8) :
_grid_x(grid_x),
_grid_y(grid_y),
_radius(radius),
_neighbors(neighbors) {}
LBPH(int radius_=1, int neighbors_=8, int grid_x_=8, int grid_y_=8) :
_grid_x(grid_x_),
_grid_y(grid_y_),
_radius(radius_),
_neighbors(neighbors_) {}
// Initializes and computes this LBPH Model. The current implementation is
// rather fixed as it uses the Extended Local Binary Patterns per default.
@ -221,12 +221,12 @@ public:
// (grid_x=8), (grid_y=8) controls the grid size of the spatial histograms.
LBPH(InputArray src,
InputArray labels,
int radius=1, int neighbors=8,
int grid_x=8, int grid_y=8) :
_grid_x(grid_x),
_grid_y(grid_y),
_radius(radius),
_neighbors(neighbors) {
int radius_=1, int neighbors_=8,
int grid_x_=8, int grid_y_=8) :
_grid_x(grid_x_),
_grid_y(grid_y_),
_radius(radius_),
_neighbors(neighbors_) {
train(src, labels);
}

View File

@ -235,19 +235,19 @@ private:
// Allocates memory.
template<typename _Tp>
_Tp **alloc_2d(int m, int n) {
_Tp **alloc_2d(int m, int _n) {
_Tp **arr = new _Tp*[m];
for (int i = 0; i < m; i++)
arr[i] = new _Tp[n];
arr[i] = new _Tp[_n];
return arr;
}
// Allocates memory.
template<typename _Tp>
_Tp **alloc_2d(int m, int n, _Tp val) {
_Tp **arr = alloc_2d<_Tp> (m, n);
_Tp **alloc_2d(int m, int _n, _Tp val) {
_Tp **arr = alloc_2d<_Tp> (m, _n);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
for (int j = 0; j < _n; j++) {
arr[i][j] = val;
}
}
@ -255,17 +255,17 @@ private:
}
void cdiv(double xr, double xi, double yr, double yi) {
double r, d;
double r, dv;
if (std::abs(yr) > std::abs(yi)) {
r = yi / yr;
d = yr + r * yi;
cdivr = (xr + r * xi) / d;
cdivi = (xi - r * xr) / d;
dv = yr + r * yi;
cdivr = (xr + r * xi) / dv;
cdivi = (xi - r * xr) / dv;
} else {
r = yr / yi;
d = yi + r * yr;
cdivr = (r * xr + xi) / d;
cdivi = (r * xi - xr) / d;
dv = yi + r * yr;
cdivr = (r * xr + xi) / dv;
cdivi = (r * xi - xr) / dv;
}
}
@ -280,7 +280,7 @@ private:
// Initialize
int nn = this->n;
int n = nn - 1;
int n1 = nn - 1;
int low = 0;
int high = nn - 1;
double eps = pow(2.0, -52.0);
@ -302,10 +302,10 @@ private:
// Outer loop over eigenvalue index
int iter = 0;
while (n >= low) {
while (n1 >= low) {
// Look for single small sub-diagonal element
int l = n;
int l = n1;
while (l > low) {
s = std::abs(H[l - 1][l - 1]) + std::abs(H[l][l]);
if (s == 0.0) {
@ -320,23 +320,23 @@ private:
// Check for convergence
// One root found
if (l == n) {
H[n][n] = H[n][n] + exshift;
d[n] = H[n][n];
e[n] = 0.0;
n--;
if (l == n1) {
H[n1][n1] = H[n1][n1] + exshift;
d[n1] = H[n1][n1];
e[n1] = 0.0;
n1--;
iter = 0;
// Two roots found
} else if (l == n - 1) {
w = H[n][n - 1] * H[n - 1][n];
p = (H[n - 1][n - 1] - H[n][n]) / 2.0;
} else if (l == n1 - 1) {
w = H[n1][n1 - 1] * H[n1 - 1][n1];
p = (H[n1 - 1][n1 - 1] - H[n1][n1]) / 2.0;
q = p * p + w;
z = sqrt(std::abs(q));
H[n][n] = H[n][n] + exshift;
H[n - 1][n - 1] = H[n - 1][n - 1] + exshift;
x = H[n][n];
H[n1][n1] = H[n1][n1] + exshift;
H[n1 - 1][n1 - 1] = H[n1 - 1][n1 - 1] + exshift;
x = H[n1][n1];
// Real pair
@ -346,14 +346,14 @@ private:
} else {
z = p - z;
}
d[n - 1] = x + z;
d[n] = d[n - 1];
d[n1 - 1] = x + z;
d[n1] = d[n1 - 1];
if (z != 0.0) {
d[n] = x - w / z;
d[n1] = x - w / z;
}
e[n - 1] = 0.0;
e[n] = 0.0;
x = H[n][n - 1];
e[n1 - 1] = 0.0;
e[n1] = 0.0;
x = H[n1][n1 - 1];
s = std::abs(x) + std::abs(z);
p = x / s;
q = z / s;
@ -363,37 +363,37 @@ private:
// Row modification
for (int j = n - 1; j < nn; j++) {
z = H[n - 1][j];
H[n - 1][j] = q * z + p * H[n][j];
H[n][j] = q * H[n][j] - p * z;
for (int j = n1 - 1; j < nn; j++) {
z = H[n1 - 1][j];
H[n1 - 1][j] = q * z + p * H[n1][j];
H[n1][j] = q * H[n1][j] - p * z;
}
// Column modification
for (int i = 0; i <= n; i++) {
z = H[i][n - 1];
H[i][n - 1] = q * z + p * H[i][n];
H[i][n] = q * H[i][n] - p * z;
for (int i = 0; i <= n1; i++) {
z = H[i][n1 - 1];
H[i][n1 - 1] = q * z + p * H[i][n1];
H[i][n1] = q * H[i][n1] - p * z;
}
// Accumulate transformations
for (int i = low; i <= high; i++) {
z = V[i][n - 1];
V[i][n - 1] = q * z + p * V[i][n];
V[i][n] = q * V[i][n] - p * z;
z = V[i][n1 - 1];
V[i][n1 - 1] = q * z + p * V[i][n1];
V[i][n1] = q * V[i][n1] - p * z;
}
// Complex pair
} else {
d[n - 1] = x + p;
d[n] = x + p;
e[n - 1] = z;
e[n] = -z;
d[n1 - 1] = x + p;
d[n1] = x + p;
e[n1 - 1] = z;
e[n1] = -z;
}
n = n - 2;
n1 = n1 - 2;
iter = 0;
// No convergence yet
@ -402,22 +402,22 @@ private:
// Form shift
x = H[n][n];
x = H[n1][n1];
y = 0.0;
w = 0.0;
if (l < n) {
y = H[n - 1][n - 1];
w = H[n][n - 1] * H[n - 1][n];
if (l < n1) {
y = H[n1 - 1][n1 - 1];
w = H[n1][n1 - 1] * H[n1 - 1][n1];
}
// Wilkinson's original ad hoc shift
if (iter == 10) {
exshift += x;
for (int i = low; i <= n; i++) {
for (int i = low; i <= n1; i++) {
H[i][i] -= x;
}
s = std::abs(H[n][n - 1]) + std::abs(H[n - 1][n - 2]);
s = std::abs(H[n1][n1 - 1]) + std::abs(H[n1 - 1][n1 - 2]);
x = y = 0.75 * s;
w = -0.4375 * s * s;
}
@ -433,7 +433,7 @@ private:
s = -s;
}
s = x - w / ((y - x) / 2.0 + s);
for (int i = low; i <= n; i++) {
for (int i = low; i <= n1; i++) {
H[i][i] -= s;
}
exshift += s;
@ -444,7 +444,7 @@ private:
iter = iter + 1; // (Could check iteration count here.)
// Look for two consecutive small sub-diagonal elements
int m = n - 2;
int m = n1 - 2;
while (m >= l) {
z = H[m][m];
r = x - z;
@ -467,7 +467,7 @@ private:
m--;
}
for (int i = m + 2; i <= n; i++) {
for (int i = m + 2; i <= n1; i++) {
H[i][i - 2] = 0.0;
if (i > m + 2) {
H[i][i - 3] = 0.0;
@ -476,8 +476,8 @@ private:
// Double QR step involving rows l:n and columns m:n
for (int k = m; k <= n - 1; k++) {
bool notlast = (k != n - 1);
for (int k = m; k <= n1 - 1; k++) {
bool notlast = (k != n1 - 1);
if (k != m) {
p = H[k][k - 1];
q = H[k + 1][k - 1];
@ -523,7 +523,7 @@ private:
// Column modification
for (int i = 0; i <= min(n, k + 3); i++) {
for (int i = 0; i <= min(n1, k + 3); i++) {
p = x * H[i][k] + y * H[i][k + 1];
if (notlast) {
p = p + z * H[i][k + 2];
@ -547,7 +547,7 @@ private:
} // (s != 0)
} // k loop
} // check convergence
} // while (n >= low)
} // while (n1 >= low)
// Backsubstitute to find vectors of upper triangular form
@ -555,20 +555,20 @@ private:
return;
}
for (n = nn - 1; n >= 0; n--) {
p = d[n];
q = e[n];
for (n1 = nn - 1; n1 >= 0; n1--) {
p = d[n1];
q = e[n1];
// Real vector
if (q == 0) {
int l = n;
H[n][n] = 1.0;
for (int i = n - 1; i >= 0; i--) {
int l = n1;
H[n1][n1] = 1.0;
for (int i = n1 - 1; i >= 0; i--) {
w = H[i][i] - p;
r = 0.0;
for (int j = l; j <= n; j++) {
r = r + H[i][j] * H[j][n];
for (int j = l; j <= n1; j++) {
r = r + H[i][j] * H[j][n1];
}
if (e[i] < 0.0) {
z = w;
@ -577,9 +577,9 @@ private:
l = i;
if (e[i] == 0.0) {
if (w != 0.0) {
H[i][n] = -r / w;
H[i][n1] = -r / w;
} else {
H[i][n] = -r / (eps * norm);
H[i][n1] = -r / (eps * norm);
}
// Solve real equations
@ -589,20 +589,20 @@ private:
y = H[i + 1][i];
q = (d[i] - p) * (d[i] - p) + e[i] * e[i];
t = (x * s - z * r) / q;
H[i][n] = t;
H[i][n1] = t;
if (std::abs(x) > std::abs(z)) {
H[i + 1][n] = (-r - w * t) / x;
H[i + 1][n1] = (-r - w * t) / x;
} else {
H[i + 1][n] = (-s - y * t) / z;
H[i + 1][n1] = (-s - y * t) / z;
}
}
// Overflow control
t = std::abs(H[i][n]);
t = std::abs(H[i][n1]);
if ((eps * t) * t > 1) {
for (int j = i; j <= n; j++) {
H[j][n] = H[j][n] / t;
for (int j = i; j <= n1; j++) {
H[j][n1] = H[j][n1] / t;
}
}
}
@ -611,27 +611,27 @@ private:
// Complex vector
} else if (q < 0) {
int l = n - 1;
int l = n1 - 1;
// Last vector component imaginary so matrix is triangular
if (std::abs(H[n][n - 1]) > std::abs(H[n - 1][n])) {
H[n - 1][n - 1] = q / H[n][n - 1];
H[n - 1][n] = -(H[n][n] - p) / H[n][n - 1];
if (std::abs(H[n1][n1 - 1]) > std::abs(H[n1 - 1][n1])) {
H[n1 - 1][n1 - 1] = q / H[n1][n1 - 1];
H[n1 - 1][n1] = -(H[n1][n1] - p) / H[n1][n1 - 1];
} else {
cdiv(0.0, -H[n - 1][n], H[n - 1][n - 1] - p, q);
H[n - 1][n - 1] = cdivr;
H[n - 1][n] = cdivi;
cdiv(0.0, -H[n1 - 1][n1], H[n1 - 1][n1 - 1] - p, q);
H[n1 - 1][n1 - 1] = cdivr;
H[n1 - 1][n1] = cdivi;
}
H[n][n - 1] = 0.0;
H[n][n] = 1.0;
for (int i = n - 2; i >= 0; i--) {
H[n1][n1 - 1] = 0.0;
H[n1][n1] = 1.0;
for (int i = n1 - 2; i >= 0; i--) {
double ra, sa, vr, vi;
ra = 0.0;
sa = 0.0;
for (int j = l; j <= n; j++) {
ra = ra + H[i][j] * H[j][n - 1];
sa = sa + H[i][j] * H[j][n];
for (int j = l; j <= n1; j++) {
ra = ra + H[i][j] * H[j][n1 - 1];
sa = sa + H[i][j] * H[j][n1];
}
w = H[i][i] - p;
@ -643,8 +643,8 @@ private:
l = i;
if (e[i] == 0) {
cdiv(-ra, -sa, w, q);
H[i][n - 1] = cdivr;
H[i][n] = cdivi;
H[i][n1 - 1] = cdivr;
H[i][n1] = cdivi;
} else {
// Solve complex equations
@ -659,28 +659,28 @@ private:
}
cdiv(x * r - z * ra + q * sa,
x * s - z * sa - q * ra, vr, vi);
H[i][n - 1] = cdivr;
H[i][n] = cdivi;
H[i][n1 - 1] = cdivr;
H[i][n1] = cdivi;
if (std::abs(x) > (std::abs(z) + std::abs(q))) {
H[i + 1][n - 1] = (-ra - w * H[i][n - 1] + q
* H[i][n]) / x;
H[i + 1][n] = (-sa - w * H[i][n] - q * H[i][n
H[i + 1][n1 - 1] = (-ra - w * H[i][n1 - 1] + q
* H[i][n1]) / x;
H[i + 1][n1] = (-sa - w * H[i][n1] - q * H[i][n1
- 1]) / x;
} else {
cdiv(-r - y * H[i][n - 1], -s - y * H[i][n], z,
cdiv(-r - y * H[i][n1 - 1], -s - y * H[i][n1], z,
q);
H[i + 1][n - 1] = cdivr;
H[i + 1][n] = cdivi;
H[i + 1][n1 - 1] = cdivr;
H[i + 1][n1] = cdivi;
}
}
// Overflow control
t = max(std::abs(H[i][n - 1]), std::abs(H[i][n]));
t = max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1]));
if ((eps * t) * t > 1) {
for (int j = i; j <= n; j++) {
H[j][n - 1] = H[j][n - 1] / t;
H[j][n] = H[j][n] / t;
for (int j = i; j <= n1; j++) {
H[j][n1 - 1] = H[j][n1 - 1] / t;
H[j][n1] = H[j][n1] / t;
}
}
}

View File

@ -62,7 +62,7 @@ namespace cv
{
//------------------------------------interp-------------------------------------------
LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int R, double ro0, int interp, int full, int S, int sp)
LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _ro0, int _interp, int full, int _S, int sp)
{
if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
@ -97,23 +97,23 @@ LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int R, double ro0
if (sp){
int jc=M/2-1, ic=N/2-1;
int romax=min(ic, jc);
double a=exp(log((double)(romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(a-1)+0.5);
int _romax=min(ic, jc);
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(_a-1)+0.5);
}
this->interp=interp;
interp=_interp;
create_map(M, N, R, S, ro0);
create_map(M, N, _R, _S, _ro0);
}
void LogPolar_Interp::create_map(int M, int N, int R, int S, double ro0)
void LogPolar_Interp::create_map(int _M, int _N, int _R, int _S, double _ro0)
{
this->M=M;
this->N=N;
this->R=R;
this->S=S;
this->ro0=ro0;
M=_M;
N=_N;
R=_R;
S=_S;
ro0=_ro0;
int jc=N/2-1, ic=M/2-1;
romax=min(ic, jc);
@ -208,7 +208,7 @@ LogPolar_Interp::~LogPolar_Interp()
//------------------------------------overlapping----------------------------------
LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int R, double ro0, int full, int S, int sp)
LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R, double _ro0, int full, int _S, int sp)
{
if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
@ -244,21 +244,21 @@ LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int R,
if (sp){
int jc=M/2-1, ic=N/2-1;
int romax=min(ic, jc);
double a=exp(log((double)(romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(a-1)+0.5);
int _romax=min(ic, jc);
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(_a-1)+0.5);
}
create_map(M, N, R, S, ro0);
create_map(M, N, _R, _S, _ro0);
}
void LogPolar_Overlapping::create_map(int M, int N, int R, int S, double ro0)
void LogPolar_Overlapping::create_map(int _M, int _N, int _R, int _S, double _ro0)
{
this->M=M;
this->N=N;
this->R=R;
this->S=S;
this->ro0=ro0;
M=_M;
N=_N;
R=_R;
S=_S;
ro0=_ro0;
int jc=N/2-1, ic=M/2-1;
romax=min(ic, jc);
@ -433,7 +433,7 @@ LogPolar_Overlapping::~LogPolar_Overlapping()
//----------------------------------------adjacent---------------------------------------
LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int R, double ro0, double smin, int full, int S, int sp)
LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int _R, double _ro0, double smin, int full, int _S, int sp)
{
if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
@ -468,22 +468,22 @@ LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int R, double
if (sp){
int jc=M/2-1, ic=N/2-1;
int romax=min(ic, jc);
double a=exp(log((double)(romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(a-1)+0.5);
int _romax=min(ic, jc);
double _a=exp(log((double)(_romax/2-1)/(double)ro0)/(double)R);
S=(int) floor(2*CV_PI/(_a-1)+0.5);
}
create_map(M, N, R, S, ro0, smin);
create_map(M, N, _R, _S, _ro0, smin);
}
void LogPolar_Adjacent::create_map(int M, int N, int R, int S, double ro0, double smin)
void LogPolar_Adjacent::create_map(int _M, int _N, int _R, int _S, double _ro0, double smin)
{
LogPolar_Adjacent::M=M;
LogPolar_Adjacent::N=N;
LogPolar_Adjacent::R=R;
LogPolar_Adjacent::S=S;
LogPolar_Adjacent::ro0=ro0;
M=_M;
N=_N;
R=_R;
S=_S;
ro0=_ro0;
romax=min(M/2.0, N/2.0);
a=exp(log(romax/ro0)/(double)R);

View File

@ -171,9 +171,9 @@ namespace cv
{
}
Octree::Octree(const vector<Point3f>& points3d, int maxLevels, int minPoints)
Octree::Octree(const vector<Point3f>& points3d, int maxLevels, int _minPoints)
{
buildTree(points3d, maxLevels, minPoints);
buildTree(points3d, maxLevels, _minPoints);
}
Octree::~Octree()
@ -256,12 +256,12 @@ namespace cv
}
}
void Octree::buildTree(const vector<Point3f>& points3d, int maxLevels, int minPoints)
void Octree::buildTree(const vector<Point3f>& points3d, int maxLevels, int _minPoints)
{
assert((size_t)maxLevels * 8 < MAX_STACK_SIZE);
points.resize(points3d.size());
std::copy(points3d.begin(), points3d.end(), points.begin());
this->minPoints = minPoints;
minPoints = _minPoints;
nodes.clear();
nodes.push_back(Node());
@ -275,7 +275,7 @@ namespace cv
for (size_t i = 0; i < MAX_LEAFS; i++)
root.children[i] = 0;
if (maxLevels != 1 && (root.end - root.begin) > minPoints)
if (maxLevels != 1 && (root.end - root.begin) > _minPoints)
{
root.isLeaf = false;
buildNext(0);

View File

@ -75,16 +75,16 @@
namespace cv
{
Retina::Retina(const cv::Size inputSize)
Retina::Retina(const cv::Size inputSz)
{
_retinaFilter = 0;
_init(inputSize, true, RETINA_COLOR_BAYER, false);
_init(inputSz, true, RETINA_COLOR_BAYER, false);
}
Retina::Retina(const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
Retina::Retina(const cv::Size inputSz, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{
_retinaFilter = 0;
_init(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
_init(inputSz, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
};
Retina::~Retina()
@ -342,20 +342,20 @@ const std::valarray<float> & Retina::getMagno() const {return _retinaFilter->get
const std::valarray<float> & Retina::getParvo() const {if (_retinaFilter->getColorMode())return _retinaFilter->getColorOutput(); /* implicite else */return _retinaFilter->getContours();}
// private method called by constructirs
void Retina::_init(const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
void Retina::_init(const cv::Size inputSz, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{
// basic error check
if (inputSize.height*inputSize.width <= 0)
if (inputSz.height*inputSz.width <= 0)
throw cv::Exception(-1, "Bad retina size setup : size height and with must be superior to zero", "Retina::setup", "Retina.h", 0);
unsigned int nbPixels=inputSize.height*inputSize.width;
unsigned int nbPixels=inputSz.height*inputSz.width;
// resize buffers if size does not match
_inputBuffer.resize(nbPixels*3); // buffer supports gray images but also 3 channels color buffers... (larger is better...)
// allocate the retina model
if (_retinaFilter)
delete _retinaFilter;
_retinaFilter = new RetinaFilter(inputSize.height, inputSize.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
_retinaFilter = new RetinaFilter(inputSz.height, inputSz.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
// prepare the default parameter XML file with default setup
setup(_retinaParameters);

View File

@ -325,15 +325,15 @@ void RetinaColor::runColorDemultiplexing(const std::valarray<float> &multiplexed
}else
{
register const float *multiplexedColorFramePTR= get_data(multiplexedColorFrame);
for (unsigned int indexc=0; indexc<_filterOutput.getNBpixels() ; ++indexc, ++chrominancePTR, ++colorLocalDensityPTR, ++luminance, ++multiplexedColorFramePTR)
register const float *multiplexedColorFramePTR1= get_data(multiplexedColorFrame);
for (unsigned int indexc=0; indexc<_filterOutput.getNBpixels() ; ++indexc, ++chrominancePTR, ++colorLocalDensityPTR, ++luminance, ++multiplexedColorFramePTR1)
{
// normalize by photoreceptors density
float Cr=*(chrominancePTR)*_colorLocalDensity[indexc];
float Cg=*(chrominancePTR+_filterOutput.getNBpixels())*_colorLocalDensity[indexc+_filterOutput.getNBpixels()];
float Cb=*(chrominancePTR+_filterOutput.getDoubleNBpixels())*_colorLocalDensity[indexc+_filterOutput.getDoubleNBpixels()];
*luminance=(Cr+Cg+Cb)*_pG;
_demultiplexedTempBuffer[_colorSampling[indexc]] = *multiplexedColorFramePTR - *luminance;
_demultiplexedTempBuffer[_colorSampling[indexc]] = *multiplexedColorFramePTR1 - *luminance;
}

View File

@ -336,18 +336,18 @@ void computeSpinImages( const Octree& Octree, const vector<Point3f>& points, con
__m128 f1f2 = _mm_mul_ps(f1, f2); // f1 * f2
__m128 omf1omf2 = _mm_add_ps(_mm_sub_ps(_mm_sub_ps(one4f, f2), f1), f1f2); // (1-f1) * (1-f2)
__m128i mask = _mm_and_si128(
__m128i _mask = _mm_and_si128(
_mm_andnot_si128(_mm_cmpgt_epi32(zero4, n1), _mm_cmpgt_epi32(height4m1, n1)),
_mm_andnot_si128(_mm_cmpgt_epi32(zero4, n2), _mm_cmpgt_epi32(width4m1, n2)));
__m128 maskf = _mm_cmpneq_ps(_mm_cvtepi32_ps(mask), zero4f);
__m128 maskf = _mm_cmpneq_ps(_mm_cvtepi32_ps(_mask), zero4f);
__m128 v00 = _mm_and_ps( omf1omf2 , maskf); // a00 b00 c00 d00
__m128 v01 = _mm_and_ps( _mm_sub_ps( f2, f1f2 ), maskf); // a01 b01 c01 d01
__m128 v10 = _mm_and_ps( _mm_sub_ps( f1, f1f2 ), maskf); // a10 b10 c10 d10
__m128 v11 = _mm_and_ps( f1f2 , maskf); // a11 b11 c11 d11
__m128i ofs4 = _mm_and_si128(_mm_add_epi32(_mm_mullo_epi32_emul(n1, step4), n2), mask);
__m128i ofs4 = _mm_and_si128(_mm_add_epi32(_mm_mullo_epi32_emul(n1, step4), n2), _mask);
_mm_store_si128((__m128i*)o, ofs4);
__m128 t0 = _mm_unpacklo_ps(v00, v01); // a00 a01 b00 b01
@ -504,16 +504,16 @@ void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& _colors)
ofstream ofs(file.c_str());
ofs << "#VRML V2.0 utf8" << endl;
ofs << "Shape" << std::endl << "{" << endl;
ofs << "geometry PointSet" << endl << "{" << endl;
ofs << "coord Coordinate" << endl << "{" << endl;
ofs << "point[" << endl;
ofs << "Shape" << std::endl << "{" << endl;
ofs << "geometry PointSet" << endl << "{" << endl;
ofs << "coord Coordinate" << endl << "{" << endl;
ofs << "point[" << endl;
for(size_t i = 0; i < vtx.size(); ++i)
ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << endl;
ofs << "]" << endl; //point[
ofs << "}" << endl; //Coordinate{
ofs << "]" << endl; //point[
ofs << "}" << endl; //Coordinate{
if (vtx.size() == _colors.size())
{
@ -524,11 +524,11 @@ void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& _colors)
ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << endl;
ofs << "]" << endl; //color[
ofs << "}" << endl; //color Color{
ofs << "}" << endl; //color Color{
}
ofs << "}" << endl; //PointSet{
ofs << "}" << endl; //Shape{
ofs << "}" << endl; //PointSet{
ofs << "}" << endl; //Shape{
}
@ -823,21 +823,21 @@ void cv::SpinImageModel::setSubset(const vector<int>& ss)
subset = ss;
}
void cv::SpinImageModel::repackSpinImages(const vector<uchar>& mask, Mat& spinImages, bool reAlloc) const
void cv::SpinImageModel::repackSpinImages(const vector<uchar>& mask, Mat& _spinImages, bool reAlloc) const
{
if (reAlloc)
{
size_t spinCount = mask.size() - count(mask.begin(), mask.end(), (uchar)0);
Mat newImgs((int)spinCount, spinImages.cols, spinImages.type());
Mat newImgs((int)spinCount, _spinImages.cols, _spinImages.type());
int pos = 0;
for(size_t t = 0; t < mask.size(); ++t)
if (mask[t])
{
Mat row = newImgs.row(pos++);
spinImages.row((int)t).copyTo(row);
_spinImages.row((int)t).copyTo(row);
}
spinImages = newImgs;
_spinImages = newImgs;
}
else
{
@ -849,13 +849,13 @@ void cv::SpinImageModel::repackSpinImages(const vector<uchar>& mask, Mat& spinIm
int first = dest + 1;
for (; first != last; ++first)
if (mask[first] != 0)
if (mask[first] != 0)
{
Mat row = spinImages.row(dest);
spinImages.row(first).copyTo(row);
Mat row = _spinImages.row(dest);
_spinImages.row(first).copyTo(row);
++dest;
}
spinImages = spinImages.rowRange(0, dest);
_spinImages = _spinImages.rowRange(0, dest);
}
}

View File

@ -67,9 +67,9 @@ StereoVar::~StereoVar()
static Mat diffX(Mat &src)
{
register int x, y, cols = src.cols - 1;
Mat dst(src.size(), src.type());
for(y = 0; y < src.rows; y++){
register int x, y, cols = src.cols - 1;
Mat dst(src.size(), src.type());
for(y = 0; y < src.rows; y++){
const float* pSrc = src.ptr<float>(y);
float* pDst = dst.ptr<float>(y);
#if CV_SSE2
@ -92,319 +92,319 @@ static Mat diffX(Mat &src)
static Mat getGradient(Mat &src)
{
register int x, y;
Mat dst(src.size(), src.type());
dst.setTo(0);
for (y = 0; y < src.rows - 1; y++) {
float *pSrc = src.ptr<float>(y);
float *pSrcF = src.ptr<float>(y + 1);
float *pDst = dst.ptr<float>(y);
for (x = 0; x < src.cols - 1; x++)
pDst[x] = fabs(pSrc[x + 1] - pSrc[x]) + fabs(pSrcF[x] - pSrc[x]);
}
return dst;
register int x, y;
Mat dst(src.size(), src.type());
dst.setTo(0);
for (y = 0; y < src.rows - 1; y++) {
float *pSrc = src.ptr<float>(y);
float *pSrcF = src.ptr<float>(y + 1);
float *pDst = dst.ptr<float>(y);
for (x = 0; x < src.cols - 1; x++)
pDst[x] = fabs(pSrc[x + 1] - pSrc[x]) + fabs(pSrcF[x] - pSrc[x]);
}
return dst;
}
static Mat getG_c(Mat &src, float l)
{
Mat dst(src.size(), src.type());
for (register int y = 0; y < src.rows; y++) {
float *pSrc = src.ptr<float>(y);
float *pDst = dst.ptr<float>(y);
for (register int x = 0; x < src.cols; x++)
pDst[x] = 0.5f*l / sqrtf(l*l + pSrc[x]*pSrc[x]);
}
return dst;
Mat dst(src.size(), src.type());
for (register int y = 0; y < src.rows; y++) {
float *pSrc = src.ptr<float>(y);
float *pDst = dst.ptr<float>(y);
for (register int x = 0; x < src.cols; x++)
pDst[x] = 0.5f*l / sqrtf(l*l + pSrc[x]*pSrc[x]);
}
return dst;
}
static Mat getG_p(Mat &src, float l)
{
Mat dst(src.size(), src.type());
for (register int y = 0; y < src.rows; y++) {
float *pSrc = src.ptr<float>(y);
float *pDst = dst.ptr<float>(y);
for (register int x = 0; x < src.cols; x++)
pDst[x] = 0.5f*l*l / (l*l + pSrc[x]*pSrc[x]);
}
return dst;
Mat dst(src.size(), src.type());
for (register int y = 0; y < src.rows; y++) {
float *pSrc = src.ptr<float>(y);
float *pDst = dst.ptr<float>(y);
for (register int x = 0; x < src.cols; x++)
pDst[x] = 0.5f*l*l / (l*l + pSrc[x]*pSrc[x]);
}
return dst;
}
void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
{
register int n, x, y;
float gl = 1, gr = 1, gu = 1, gd = 1, gc = 4;
Mat g_c, g_p;
Mat U;
u.copyTo(U);
register int n, x, y;
float gl = 1, gr = 1, gu = 1, gd = 1, gc = 4;
Mat g_c, g_p;
Mat U;
u.copyTo(U);
int N = nIt;
float l = lambda;
float Fi = fi;
int N = nIt;
float l = lambda;
float Fi = fi;
if (flags & USE_SMART_ID) {
double scale = pow(pyrScale, (double) level) * (1 + pyrScale);
N = (int) (N / scale);
}
if (flags & USE_SMART_ID) {
double scale = pow(pyrScale, (double) level) * (1 + pyrScale);
N = (int) (N / scale);
}
double scale = pow(pyrScale, (double) level);
Fi /= (float) scale;
l *= (float) scale;
double scale = pow(pyrScale, (double) level);
Fi /= (float) scale;
l *= (float) scale;
int width = u.cols - 1;
int height = u.rows - 1;
for (n = 0; n < N; n++) {
if (penalization != PENALIZATION_TICHONOV) {
Mat gradient = getGradient(U);
switch (penalization) {
case PENALIZATION_CHARBONNIER: g_c = getG_c(gradient, l); break;
case PENALIZATION_PERONA_MALIK: g_p = getG_p(gradient, l); break;
}
gradient.release();
}
for (y = 1 ; y < height; y++) {
float *pU = U.ptr<float>(y);
float *pUu = U.ptr<float>(y + 1);
float *pUd = U.ptr<float>(y - 1);
float *pu = u.ptr<float>(y);
float *pI1 = I1.ptr<float>(y);
float *pI2 = I2.ptr<float>(y);
float *pI2x = I2x.ptr<float>(y);
float *pG_c = NULL, *pG_cu = NULL, *pG_cd = NULL;
float *pG_p = NULL, *pG_pu = NULL, *pG_pd = NULL;
switch (penalization) {
case PENALIZATION_CHARBONNIER:
pG_c = g_c.ptr<float>(y);
pG_cu = g_c.ptr<float>(y + 1);
pG_cd = g_c.ptr<float>(y - 1);
break;
case PENALIZATION_PERONA_MALIK:
pG_p = g_p.ptr<float>(y);
pG_pu = g_p.ptr<float>(y + 1);
pG_pd = g_p.ptr<float>(y - 1);
break;
}
for (x = 1; x < width; x++) {
switch (penalization) {
case PENALIZATION_CHARBONNIER:
gc = pG_c[x];
gl = gc + pG_c[x - 1];
gr = gc + pG_c[x + 1];
gu = gc + pG_cu[x];
gd = gc + pG_cd[x];
gc = gl + gr + gu + gd;
break;
case PENALIZATION_PERONA_MALIK:
gc = pG_p[x];
gl = gc + pG_p[x - 1];
gr = gc + pG_p[x + 1];
gu = gc + pG_pu[x];
gd = gc + pG_pd[x];
gc = gl + gr + gu + gd;
break;
}
int width = u.cols - 1;
int height = u.rows - 1;
for (n = 0; n < N; n++) {
if (penalization != PENALIZATION_TICHONOV) {
Mat gradient = getGradient(U);
switch (penalization) {
case PENALIZATION_CHARBONNIER: g_c = getG_c(gradient, l); break;
case PENALIZATION_PERONA_MALIK: g_p = getG_p(gradient, l); break;
}
gradient.release();
}
for (y = 1 ; y < height; y++) {
float *pU = U.ptr<float>(y);
float *pUu = U.ptr<float>(y + 1);
float *pUd = U.ptr<float>(y - 1);
float *pu = u.ptr<float>(y);
float *pI1 = I1.ptr<float>(y);
float *pI2 = I2.ptr<float>(y);
float *pI2x = I2x.ptr<float>(y);
float *pG_c = NULL, *pG_cu = NULL, *pG_cd = NULL;
float *pG_p = NULL, *pG_pu = NULL, *pG_pd = NULL;
switch (penalization) {
case PENALIZATION_CHARBONNIER:
pG_c = g_c.ptr<float>(y);
pG_cu = g_c.ptr<float>(y + 1);
pG_cd = g_c.ptr<float>(y - 1);
break;
case PENALIZATION_PERONA_MALIK:
pG_p = g_p.ptr<float>(y);
pG_pu = g_p.ptr<float>(y + 1);
pG_pd = g_p.ptr<float>(y - 1);
break;
}
for (x = 1; x < width; x++) {
switch (penalization) {
case PENALIZATION_CHARBONNIER:
gc = pG_c[x];
gl = gc + pG_c[x - 1];
gr = gc + pG_c[x + 1];
gu = gc + pG_cu[x];
gd = gc + pG_cd[x];
gc = gl + gr + gu + gd;
break;
case PENALIZATION_PERONA_MALIK:
gc = pG_p[x];
gl = gc + pG_p[x - 1];
gr = gc + pG_p[x + 1];
gu = gc + pG_pu[x];
gd = gc + pG_pd[x];
gc = gl + gr + gu + gd;
break;
}
float fi = Fi;
if (maxDisp > minDisp) {
if (pU[x] > maxDisp * scale) {fi *= 1000; pU[x] = static_cast<float>(maxDisp * scale);}
if (pU[x] < minDisp * scale) {fi *= 1000; pU[x] = static_cast<float>(minDisp * scale);}
}
float _fi = Fi;
if (maxDisp > minDisp) {
if (pU[x] > maxDisp * scale) {_fi *= 1000; pU[x] = static_cast<float>(maxDisp * scale);}
if (pU[x] < minDisp * scale) {_fi *= 1000; pU[x] = static_cast<float>(minDisp * scale);}
}
int A = static_cast<int>(pU[x]);
int neg = 0; if (pU[x] <= 0) neg = -1;
int A = static_cast<int>(pU[x]);
int neg = 0; if (pU[x] <= 0) neg = -1;
if (x + A > width)
pu[x] = pU[width - A];
else if (x + A + neg < 0)
pu[x] = pU[- A + 2];
else {
pu[x] = A + (pI2x[x + A + neg] * (pI1[x] - pI2[x + A])
+ fi * (gr * pU[x + 1] + gl * pU[x - 1] + gu * pUu[x] + gd * pUd[x] - gc * A))
/ (pI2x[x + A + neg] * pI2x[x + A + neg] + gc * fi) ;
}
}// x
pu[0] = pu[1];
pu[width] = pu[width - 1];
}// y
for (x = 0; x <= width; x++) {
u.at<float>(0, x) = u.at<float>(1, x);
u.at<float>(height, x) = u.at<float>(height - 1, x);
}
u.copyTo(U);
if (!g_c.empty()) g_c.release();
if (!g_p.empty()) g_p.release();
}//n
if (x + A > width)
pu[x] = pU[width - A];
else if (x + A + neg < 0)
pu[x] = pU[- A + 2];
else {
pu[x] = A + (pI2x[x + A + neg] * (pI1[x] - pI2[x + A])
+ _fi * (gr * pU[x + 1] + gl * pU[x - 1] + gu * pUu[x] + gd * pUd[x] - gc * A))
/ (pI2x[x + A + neg] * pI2x[x + A + neg] + gc * _fi) ;
}
}// x
pu[0] = pu[1];
pu[width] = pu[width - 1];
}// y
for (x = 0; x <= width; x++) {
u.at<float>(0, x) = u.at<float>(1, x);
u.at<float>(height, x) = u.at<float>(height - 1, x);
}
u.copyTo(U);
if (!g_c.empty()) g_c.release();
if (!g_p.empty()) g_p.release();
}//n
}
void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level)
{
CvSize imgSize = _u.size();
CvSize frmSize = cvSize((int) (imgSize.width * pyrScale + 0.5), (int) (imgSize.height * pyrScale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h, U, U_h;
CvSize imgSize = _u.size();
CvSize frmSize = cvSize((int) (imgSize.width * pyrScale + 0.5), (int) (imgSize.height * pyrScale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h, U, U_h;
//PRE relaxation
VariationalSolver(I1, I2, I2x, _u, level);
//PRE relaxation
VariationalSolver(I1, I2, I2x, _u, level);
if (level >= levels - 1) return;
level ++;
if (level >= levels - 1) return;
level ++;
//scaling DOWN
resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
resize(_u, u_h, frmSize, 0, 0, INTER_AREA);
u_h.convertTo(u_h, u_h.type(), pyrScale);
I2x_h = diffX(I2_h);
//scaling DOWN
resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
resize(_u, u_h, frmSize, 0, 0, INTER_AREA);
u_h.convertTo(u_h, u_h.type(), pyrScale);
I2x_h = diffX(I2_h);
//Next level
U_h = u_h.clone();
VCycle_MyFAS(I1_h, I2_h, I2x_h, U_h, level);
//Next level
U_h = u_h.clone();
VCycle_MyFAS(I1_h, I2_h, I2x_h, U_h, level);
subtract(U_h, u_h, U_h);
U_h.convertTo(U_h, U_h.type(), 1.0 / pyrScale);
subtract(U_h, u_h, U_h);
U_h.convertTo(U_h, U_h.type(), 1.0 / pyrScale);
//scaling UP
resize(U_h, U, imgSize);
//scaling UP
resize(U_h, U, imgSize);
//correcting the solution
add(_u, U, _u);
//correcting the solution
add(_u, U, _u);
//POST relaxation
VariationalSolver(I1, I2, I2x, _u, level - 1);
//POST relaxation
VariationalSolver(I1, I2, I2x, _u, level - 1);
if (flags & USE_MEDIAN_FILTERING) medianBlur(_u, _u, 3);
if (flags & USE_MEDIAN_FILTERING) medianBlur(_u, _u, 3);
I1_h.release();
I2_h.release();
I2x_h.release();
u_h.release();
U.release();
U_h.release();
I1_h.release();
I2_h.release();
I2x_h.release();
u_h.release();
U.release();
U_h.release();
}
void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
{
double scale = pow(pyrScale, (double) level);
CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h;
double scale = pow(pyrScale, (double) level);
CvSize frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
Mat I1_h, I2_h, I2x_h, u_h;
//scaling DOWN
resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
resize(u, u_h, frmSize, 0, 0, INTER_AREA);
u_h.convertTo(u_h, u_h.type(), scale);
I2x_h = diffX(I2_h);
//scaling DOWN
resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
resize(u, u_h, frmSize, 0, 0, INTER_AREA);
u_h.convertTo(u_h, u_h.type(), scale);
I2x_h = diffX(I2_h);
switch (cycle) {
case CYCLE_O:
VariationalSolver(I1_h, I2_h, I2x_h, u_h, level);
break;
case CYCLE_V:
VCycle_MyFAS(I1_h, I2_h, I2x_h, u_h, level);
break;
}
switch (cycle) {
case CYCLE_O:
VariationalSolver(I1_h, I2_h, I2x_h, u_h, level);
break;
case CYCLE_V:
VCycle_MyFAS(I1_h, I2_h, I2x_h, u_h, level);
break;
}
u_h.convertTo(u_h, u_h.type(), 1.0 / scale);
u_h.convertTo(u_h, u_h.type(), 1.0 / scale);
//scaling UP
resize(u_h, u, u.size(), 0, 0, INTER_CUBIC);
//scaling UP
resize(u_h, u, u.size(), 0, 0, INTER_CUBIC);
I1_h.release();
I2_h.release();
I2x_h.release();
u_h.release();
I1_h.release();
I2_h.release();
I2x_h.release();
u_h.release();
level--;
if ((flags & USE_AUTO_PARAMS) && (level < levels / 3)) {
penalization = PENALIZATION_PERONA_MALIK;
fi *= 100;
flags -= USE_AUTO_PARAMS;
autoParams();
}
if (flags & USE_MEDIAN_FILTERING) medianBlur(u, u, 3);
if (level >= 0) FMG(I1, I2, I2x, u, level);
level--;
if ((flags & USE_AUTO_PARAMS) && (level < levels / 3)) {
penalization = PENALIZATION_PERONA_MALIK;
fi *= 100;
flags -= USE_AUTO_PARAMS;
autoParams();
}
if (flags & USE_MEDIAN_FILTERING) medianBlur(u, u, 3);
if (level >= 0) FMG(I1, I2, I2x, u, level);
}
void StereoVar::autoParams()
{
int maxD = MAX(labs(maxDisp), labs(minDisp));
int maxD = MAX(labs(maxDisp), labs(minDisp));
if (!maxD) pyrScale = 0.85;
else if (maxD < 8) pyrScale = 0.5;
else if (maxD < 64) pyrScale = 0.5 + static_cast<double>(maxD - 8) * 0.00625;
else pyrScale = 0.85;
if (!maxD) pyrScale = 0.85;
else if (maxD < 8) pyrScale = 0.5;
else if (maxD < 64) pyrScale = 0.5 + static_cast<double>(maxD - 8) * 0.00625;
else pyrScale = 0.85;
if (maxD) {
levels = 0;
while ( pow(pyrScale, levels) * maxD > 1.5) levels ++;
levels++;
}
if (maxD) {
levels = 0;
while ( pow(pyrScale, levels) * maxD > 1.5) levels ++;
levels++;
}
switch(penalization) {
case PENALIZATION_TICHONOV: cycle = CYCLE_V; break;
case PENALIZATION_CHARBONNIER: cycle = CYCLE_O; break;
case PENALIZATION_PERONA_MALIK: cycle = CYCLE_O; break;
}
switch(penalization) {
case PENALIZATION_TICHONOV: cycle = CYCLE_V; break;
case PENALIZATION_CHARBONNIER: cycle = CYCLE_O; break;
case PENALIZATION_PERONA_MALIK: cycle = CYCLE_O; break;
}
}
void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp )
{
CV_Assert(left.size() == right.size() && left.type() == right.type());
CvSize imgSize = left.size();
int MaxD = MAX(labs(minDisp), labs(maxDisp));
int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1;
if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;}
CV_Assert(left.size() == right.size() && left.type() == right.type());
CvSize imgSize = left.size();
int MaxD = MAX(labs(minDisp), labs(maxDisp));
int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1;
if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;}
Mat u;
if ((flags & USE_INITIAL_DISPARITY) && (!disp.empty())) {
CV_Assert(disp.size() == left.size() && disp.type() == CV_8UC1);
disp.convertTo(u, CV_32FC1, static_cast<double>(SignD * MaxD) / 256);
} else {
u.create(imgSize, CV_32FC1);
u.setTo(0);
}
Mat u;
if ((flags & USE_INITIAL_DISPARITY) && (!disp.empty())) {
CV_Assert(disp.size() == left.size() && disp.type() == CV_8UC1);
disp.convertTo(u, CV_32FC1, static_cast<double>(SignD * MaxD) / 256);
} else {
u.create(imgSize, CV_32FC1);
u.setTo(0);
}
// Preprocessing
Mat leftgray, rightgray;
if (left.type() != CV_8UC1) {
cvtColor(left, leftgray, CV_BGR2GRAY);
cvtColor(right, rightgray, CV_BGR2GRAY);
} else {
left.copyTo(leftgray);
right.copyTo(rightgray);
}
if (flags & USE_EQUALIZE_HIST) {
equalizeHist(leftgray, leftgray);
equalizeHist(rightgray, rightgray);
}
if (poly_sigma > 0.0001) {
GaussianBlur(leftgray, leftgray, cvSize(poly_n, poly_n), poly_sigma);
GaussianBlur(rightgray, rightgray, cvSize(poly_n, poly_n), poly_sigma);
}
// Preprocessing
Mat leftgray, rightgray;
if (left.type() != CV_8UC1) {
cvtColor(left, leftgray, CV_BGR2GRAY);
cvtColor(right, rightgray, CV_BGR2GRAY);
} else {
left.copyTo(leftgray);
right.copyTo(rightgray);
}
if (flags & USE_EQUALIZE_HIST) {
equalizeHist(leftgray, leftgray);
equalizeHist(rightgray, rightgray);
}
if (poly_sigma > 0.0001) {
GaussianBlur(leftgray, leftgray, cvSize(poly_n, poly_n), poly_sigma);
GaussianBlur(rightgray, rightgray, cvSize(poly_n, poly_n), poly_sigma);
}
if (flags & USE_AUTO_PARAMS) {
penalization = PENALIZATION_TICHONOV;
autoParams();
}
if (flags & USE_AUTO_PARAMS) {
penalization = PENALIZATION_TICHONOV;
autoParams();
}
Mat I1, I2;
leftgray.convertTo(I1, CV_32FC1);
rightgray.convertTo(I2, CV_32FC1);
leftgray.release();
rightgray.release();
Mat I1, I2;
leftgray.convertTo(I1, CV_32FC1);
rightgray.convertTo(I2, CV_32FC1);
leftgray.release();
rightgray.release();
Mat I2x = diffX(I2);
Mat I2x = diffX(I2);
FMG(I1, I2, I2x, u, levels - 1);
FMG(I1, I2, I2x, u, levels - 1);
I1.release();
I2.release();
I2x.release();
I1.release();
I2.release();
I2x.release();
disp.create( left.size(), CV_8UC1 );
u = abs(u);
u.convertTo(disp, disp.type(), 256 / MaxD, 0);
disp.create( left.size(), CV_8UC1 );
u = abs(u);
u.convertTo(disp, disp.type(), 256 / MaxD, 0);
u.release();
u.release();
}
} // namespace

View File

@ -5,12 +5,10 @@ ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
if(HAVE_CUDA)
file(GLOB lib_cuda "src/cuda/*.cu")
source_group("Cuda" FILES "${lib_cuda}")
include_directories(AFTER SYSTEM ${CUDA_INCLUDE_DIRS})
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda")
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda" ${CUDA_INCLUDE_DIRS})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
OCV_CUDA_COMPILE(cuda_objs ${lib_cuda})
ocv_cuda_compile(cuda_objs ${lib_cuda})
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
else()

View File

@ -366,12 +366,12 @@ namespace cv { namespace gpu
return m;
}
inline void GpuMat::assignTo(GpuMat& m, int type) const
inline void GpuMat::assignTo(GpuMat& m, int _type) const
{
if (type < 0)
if (_type < 0)
m = *this;
else
convertTo(m, type);
convertTo(m, _type);
}
inline size_t GpuMat::step1() const
@ -434,9 +434,9 @@ namespace cv { namespace gpu
create(size_.height, size_.width, type_);
}
inline GpuMat GpuMat::operator()(Range rowRange, Range colRange) const
inline GpuMat GpuMat::operator()(Range _rowRange, Range _colRange) const
{
return GpuMat(*this, rowRange, colRange);
return GpuMat(*this, _rowRange, _colRange);
}
inline GpuMat GpuMat::operator()(Rect roi) const

View File

@ -336,12 +336,12 @@ inline Mat Mat::clone() const
return m;
}
inline void Mat::assignTo( Mat& m, int type ) const
inline void Mat::assignTo( Mat& m, int _type ) const
{
if( type < 0 )
if( _type < 0 )
m = *this;
else
convertTo(m, type);
convertTo(m, _type);
}
inline void Mat::create(int _rows, int _cols, int _type)
@ -370,9 +370,9 @@ inline void Mat::release()
refcount = 0;
}
inline Mat Mat::operator()( Range rowRange, Range colRange ) const
inline Mat Mat::operator()( Range _rowRange, Range _colRange ) const
{
return Mat(*this, rowRange, colRange);
return Mat(*this, _rowRange, _colRange);
}
inline Mat Mat::operator()( const Rect& roi ) const
@ -682,11 +682,11 @@ template<typename _Tp, int m, int n> inline Mat::operator Matx<_Tp, m, n>() cons
template<typename _Tp> inline void Mat::push_back(const _Tp& elem)
{
if( !data )
{
*this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone();
return;
}
CV_Assert(DataType<_Tp>::type == type() && cols == 1
{
*this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone();
return;
}
CV_Assert(DataType<_Tp>::type == type() && cols == 1
/* && dims == 2 (cols == 1 implies dims == 2) */);
uchar* tmp = dataend + step[0];
if( !isSubmatrix() && isContinuous() && tmp <= datalimit )
@ -829,8 +829,8 @@ template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m)
template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps)
: Mat(_rows, _cols, DataType<_Tp>::type, _data, steps) {}
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Range& rowRange, const Range& colRange)
: Mat(m, rowRange, colRange) {}
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Range& _rowRange, const Range& _colRange)
: Mat(m, _rowRange, _colRange) {}
template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi)
: Mat(m, roi) {}
@ -967,8 +967,8 @@ template<typename _Tp> inline size_t Mat_<_Tp>::step1(int i) const { return step
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright )
{ return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); }
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range& rowRange, const Range& colRange ) const
{ return Mat_<_Tp>(*this, rowRange, colRange); }
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range& _rowRange, const Range& _colRange ) const
{ return Mat_<_Tp>(*this, _rowRange, _colRange); }
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const
{ return Mat_<_Tp>(*this, roi); }
@ -2123,12 +2123,12 @@ inline SparseMat SparseMat::clone() const
}
inline void SparseMat::assignTo( SparseMat& m, int type ) const
inline void SparseMat::assignTo( SparseMat& m, int _type ) const
{
if( type < 0 )
if( _type < 0 )
m = *this;
else
convertTo(m, type);
convertTo(m, _type);
}
inline void SparseMat::addref()

View File

@ -49,280 +49,285 @@
namespace cv
{
//! Smart pointer for OpenGL buffer memory with reference counting.
class CV_EXPORTS GlBuffer
//! Smart pointer for OpenGL buffer memory with reference counting.
class CV_EXPORTS GlBuffer
{
public:
enum Usage
{
public:
enum Usage
{
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
};
//! create empty buffer
explicit GlBuffer(Usage usage);
//! create buffer
GlBuffer(int rows, int cols, int type, Usage usage);
GlBuffer(Size size, int type, Usage usage);
//! copy from host/device memory
GlBuffer(InputArray mat, Usage usage);
void create(int rows, int cols, int type, Usage usage);
inline void create(Size size, int type, Usage usage) { create(size.height, size.width, type, usage); }
inline void create(int rows, int cols, int type) { create(rows, cols, type, usage()); }
inline void create(Size size, int type) { create(size.height, size.width, type, usage()); }
void release();
//! copy from host/device memory
void copyFrom(InputArray mat);
void bind() const;
void unbind() const;
//! map to host memory
Mat mapHost();
void unmapHost();
//! map to device memory
gpu::GpuMat mapDevice();
void unmapDevice();
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
inline Usage usage() const { return usage_; }
class Impl;
private:
int rows_;
int cols_;
int type_;
Usage usage_;
Ptr<Impl> impl_;
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
};
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
//! create empty buffer
explicit GlBuffer(Usage usage);
//! Smart pointer for OpenGL 2d texture memory with reference counting.
class CV_EXPORTS GlTexture
//! create buffer
GlBuffer(int rows, int cols, int type, Usage usage);
GlBuffer(Size size, int type, Usage usage);
//! copy from host/device memory
GlBuffer(InputArray mat, Usage usage);
void create(int rows, int cols, int type, Usage usage);
void create(Size size, int type, Usage usage);
void create(int rows, int cols, int type);
void create(Size size, int type);
void release();
//! copy from host/device memory
void copyFrom(InputArray mat);
void bind() const;
void unbind() const;
//! map to host memory
Mat mapHost();
void unmapHost();
//! map to device memory
gpu::GpuMat mapDevice();
void unmapDevice();
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
inline Usage usage() const { return usage_; }
class Impl;
private:
int rows_;
int cols_;
int type_;
Usage usage_;
Ptr<Impl> impl_;
};
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
//! Smart pointer for OpenGL 2d texture memory with reference counting.
class CV_EXPORTS GlTexture
{
public:
//! create empty texture
GlTexture();
//! create texture
GlTexture(int rows, int cols, int type);
GlTexture(Size size, int type);
//! copy from host/device memory
explicit GlTexture(InputArray mat, bool bgra = true);
void create(int rows, int cols, int type);
void create(Size size, int type);
void release();
//! copy from host/device memory
void copyFrom(InputArray mat, bool bgra = true);
void bind() const;
void unbind() const;
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
class Impl;
private:
int rows_;
int cols_;
int type_;
Ptr<Impl> impl_;
GlBuffer buf_;
};
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
//! OpenGL Arrays
class CV_EXPORTS GlArrays
{
public:
inline GlArrays()
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
{
public:
//! create empty texture
GlTexture();
//! create texture
GlTexture(int rows, int cols, int type);
GlTexture(Size size, int type);
//! copy from host/device memory
explicit GlTexture(InputArray mat, bool bgra = true);
void create(int rows, int cols, int type);
inline void create(Size size, int type) { create(size.height, size.width, type); }
void release();
//! copy from host/device memory
void copyFrom(InputArray mat, bool bgra = true);
void bind() const;
void unbind() const;
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
class Impl;
private:
int rows_;
int cols_;
int type_;
Ptr<Impl> impl_;
GlBuffer buf_;
};
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
//! OpenGL Arrays
class CV_EXPORTS GlArrays
{
public:
inline GlArrays()
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
{
}
void setVertexArray(InputArray vertex);
inline void resetVertexArray() { vertex_.release(); }
void setColorArray(InputArray color, bool bgra = true);
inline void resetColorArray() { color_.release(); }
void setNormalArray(InputArray normal);
inline void resetNormalArray() { normal_.release(); }
void setTexCoordArray(InputArray texCoord);
inline void resetTexCoordArray() { texCoord_.release(); }
void bind() const;
void unbind() const;
inline int rows() const { return vertex_.rows(); }
inline int cols() const { return vertex_.cols(); }
inline Size size() const { return vertex_.size(); }
inline bool empty() const { return vertex_.empty(); }
private:
GlBuffer vertex_;
GlBuffer color_;
bool bgra_;
GlBuffer normal_;
GlBuffer texCoord_;
};
//! OpenGL Font
class CV_EXPORTS GlFont
{
public:
enum Weight
{
WEIGHT_LIGHT = 300,
WEIGHT_NORMAL = 400,
WEIGHT_SEMIBOLD = 600,
WEIGHT_BOLD = 700,
WEIGHT_BLACK = 900
};
enum Style
{
STYLE_NORMAL = 0,
STYLE_ITALIC = 1,
STYLE_UNDERLINE = 2
};
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
void draw(const char* str, size_t len) const;
inline const std::string& family() const { return family_; }
inline int height() const { return height_; }
inline Weight weight() const { return weight_; }
inline Style style() const { return style_; }
private:
GlFont(const std::string& family, int height, Weight weight, Style style);
std::string family_;
int height_;
Weight weight_;
Style style_;
unsigned int base_;
GlFont(const GlFont&);
GlFont& operator =(const GlFont&);
};
//! render functions
//! render texture rectangle in window
CV_EXPORTS void render(const GlTexture& tex,
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
//! render mode
namespace RenderMode {
enum {
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
LINE_STRIP = 0x0003,
TRIANGLES = 0x0004,
TRIANGLE_STRIP = 0x0005,
TRIANGLE_FAN = 0x0006,
QUADS = 0x0007,
QUAD_STRIP = 0x0008,
POLYGON = 0x0009
};
}
//! render OpenGL arrays
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
void setVertexArray(InputArray vertex);
inline void resetVertexArray() { vertex_.release(); }
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
void setColorArray(InputArray color, bool bgra = true);
inline void resetColorArray() { color_.release(); }
//! OpenGL camera
class CV_EXPORTS GlCamera
void setNormalArray(InputArray normal);
inline void resetNormalArray() { normal_.release(); }
void setTexCoordArray(InputArray texCoord);
inline void resetTexCoordArray() { texCoord_.release(); }
void bind() const;
void unbind() const;
inline int rows() const { return vertex_.rows(); }
inline int cols() const { return vertex_.cols(); }
inline Size size() const { return vertex_.size(); }
inline bool empty() const { return vertex_.empty(); }
private:
GlBuffer vertex_;
GlBuffer color_;
bool bgra_;
GlBuffer normal_;
GlBuffer texCoord_;
};
//! OpenGL Font
class CV_EXPORTS GlFont
{
public:
enum Weight
{
public:
GlCamera();
void lookAt(Point3d eye, Point3d center, Point3d up);
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
void setScale(Point3d scale);
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
void setupProjectionMatrix() const;
void setupModelViewMatrix() const;
private:
Point3d eye_;
Point3d center_;
Point3d up_;
Point3d pos_;
double yaw_;
double pitch_;
double roll_;
bool useLookAtParams_;
Point3d scale_;
Mat projectionMatrix_;
double fov_;
double aspect_;
double left_;
double right_;
double bottom_;
double top_;
double zNear_;
double zFar_;
bool perspectiveProjection_;
WEIGHT_LIGHT = 300,
WEIGHT_NORMAL = 400,
WEIGHT_SEMIBOLD = 600,
WEIGHT_BOLD = 700,
WEIGHT_BLACK = 900
};
namespace gpu
enum Style
{
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS void setGlDevice(int device = 0);
}
STYLE_NORMAL = 0,
STYLE_ITALIC = 1,
STYLE_UNDERLINE = 2
};
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
void draw(const char* str, size_t len) const;
inline const std::string& family() const { return family_; }
inline int height() const { return height_; }
inline Weight weight() const { return weight_; }
inline Style style() const { return style_; }
private:
GlFont(const std::string& family, int height, Weight weight, Style style);
std::string family_;
int height_;
Weight weight_;
Style style_;
unsigned int base_;
GlFont(const GlFont&);
GlFont& operator =(const GlFont&);
};
//! render functions
//! render texture rectangle in window
CV_EXPORTS void render(const GlTexture& tex,
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
//! render mode
namespace RenderMode {
enum {
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
LINE_STRIP = 0x0003,
TRIANGLES = 0x0004,
TRIANGLE_STRIP = 0x0005,
TRIANGLE_FAN = 0x0006,
QUADS = 0x0007,
QUAD_STRIP = 0x0008,
POLYGON = 0x0009
};
}
//! render OpenGL arrays
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
//! OpenGL camera
class CV_EXPORTS GlCamera
{
public:
GlCamera();
void lookAt(Point3d eye, Point3d center, Point3d up);
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
void setScale(Point3d scale);
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
void setupProjectionMatrix() const;
void setupModelViewMatrix() const;
private:
Point3d eye_;
Point3d center_;
Point3d up_;
Point3d pos_;
double yaw_;
double pitch_;
double roll_;
bool useLookAtParams_;
Point3d scale_;
Mat projectionMatrix_;
double fov_;
double aspect_;
double left_;
double right_;
double bottom_;
double top_;
double zNear_;
double zFar_;
bool perspectiveProjection_;
};
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
namespace gpu
{
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS void setGlDevice(int device = 0);
}
} // namespace cv
#endif // __cplusplus

View File

@ -2616,20 +2616,20 @@ template<typename _Tp> inline void Ptr<_Tp>::delete_obj()
template<typename _Tp> inline Ptr<_Tp>::~Ptr() { release(); }
template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& ptr)
template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& _ptr)
{
obj = ptr.obj;
refcount = ptr.refcount;
obj = _ptr.obj;
refcount = _ptr.refcount;
addref();
}
template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& ptr)
template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& _ptr)
{
int* _refcount = ptr.refcount;
int* _refcount = _ptr.refcount;
if( _refcount )
CV_XADD(_refcount, 1);
release();
obj = ptr.obj;
obj = _ptr.obj;
refcount = _refcount;
return *this;
}
@ -3593,10 +3593,10 @@ template<typename _Tp> inline Seq<_Tp>::operator vector<_Tp>() const
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator()
{ memset(this, 0, sizeof(*this)); }
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& seq, bool seekEnd)
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& _seq, bool seekEnd)
{
cvStartReadSeq(seq.seq, this);
index = seekEnd ? seq.seq->total : 0;
cvStartReadSeq(_seq.seq, this);
index = seekEnd ? _seq.seq->total : 0;
}
template<typename _Tp> inline void SeqIterator<_Tp>::seek(size_t pos)
@ -3842,17 +3842,17 @@ template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name)
return _create(name).ptr<_Tp>();
}
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& name) const
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const
{
typename ParamType<_Tp>::member_type value;
info()->get(this, name.c_str(), ParamType<_Tp>::type, &value);
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
return value;
}
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* name) const
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* _name) const
{
typename ParamType<_Tp>::member_type value;
info()->get(this, name, ParamType<_Tp>::type, &value);
info()->get(this, _name, ParamType<_Tp>::type, &value);
return value;
}

View File

@ -181,124 +181,124 @@ string Algorithm::name() const
return info()->name();
}
void Algorithm::set(const string& name, int value)
void Algorithm::set(const string& parameter, int value)
{
info()->set(this, name.c_str(), ParamType<int>::type, &value);
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
}
void Algorithm::set(const string& name, double value)
void Algorithm::set(const string& parameter, double value)
{
info()->set(this, name.c_str(), ParamType<double>::type, &value);
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
}
void Algorithm::set(const string& name, bool value)
void Algorithm::set(const string& parameter, bool value)
{
info()->set(this, name.c_str(), ParamType<bool>::type, &value);
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
}
void Algorithm::set(const string& name, const string& value)
void Algorithm::set(const string& parameter, const string& value)
{
info()->set(this, name.c_str(), ParamType<string>::type, &value);
info()->set(this, parameter.c_str(), ParamType<string>::type, &value);
}
void Algorithm::set(const string& name, const Mat& value)
void Algorithm::set(const string& parameter, const Mat& value)
{
info()->set(this, name.c_str(), ParamType<Mat>::type, &value);
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
}
void Algorithm::set(const string& name, const vector<Mat>& value)
void Algorithm::set(const string& parameter, const vector<Mat>& value)
{
info()->set(this, name.c_str(), ParamType<vector<Mat> >::type, &value);
info()->set(this, parameter.c_str(), ParamType<vector<Mat> >::type, &value);
}
void Algorithm::set(const string& name, const Ptr<Algorithm>& value)
void Algorithm::set(const string& parameter, const Ptr<Algorithm>& value)
{
info()->set(this, name.c_str(), ParamType<Algorithm>::type, &value);
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
}
void Algorithm::set(const char* name, int value)
void Algorithm::set(const char* parameter, int value)
{
info()->set(this, name, ParamType<int>::type, &value);
info()->set(this, parameter, ParamType<int>::type, &value);
}
void Algorithm::set(const char* name, double value)
void Algorithm::set(const char* parameter, double value)
{
info()->set(this, name, ParamType<double>::type, &value);
info()->set(this, parameter, ParamType<double>::type, &value);
}
void Algorithm::set(const char* name, bool value)
void Algorithm::set(const char* parameter, bool value)
{
info()->set(this, name, ParamType<bool>::type, &value);
info()->set(this, parameter, ParamType<bool>::type, &value);
}
void Algorithm::set(const char* name, const string& value)
void Algorithm::set(const char* parameter, const string& value)
{
info()->set(this, name, ParamType<string>::type, &value);
info()->set(this, parameter, ParamType<string>::type, &value);
}
void Algorithm::set(const char* name, const Mat& value)
void Algorithm::set(const char* parameter, const Mat& value)
{
info()->set(this, name, ParamType<Mat>::type, &value);
info()->set(this, parameter, ParamType<Mat>::type, &value);
}
void Algorithm::set(const char* name, const vector<Mat>& value)
void Algorithm::set(const char* parameter, const vector<Mat>& value)
{
info()->set(this, name, ParamType<vector<Mat> >::type, &value);
info()->set(this, parameter, ParamType<vector<Mat> >::type, &value);
}
void Algorithm::set(const char* name, const Ptr<Algorithm>& value)
void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
{
info()->set(this, name, ParamType<Algorithm>::type, &value);
info()->set(this, parameter, ParamType<Algorithm>::type, &value);
}
int Algorithm::getInt(const string& name) const
int Algorithm::getInt(const string& parameter) const
{
return get<int>(name);
return get<int>(parameter);
}
double Algorithm::getDouble(const string& name) const
double Algorithm::getDouble(const string& parameter) const
{
return get<double>(name);
return get<double>(parameter);
}
bool Algorithm::getBool(const string& name) const
bool Algorithm::getBool(const string& parameter) const
{
return get<bool>(name);
return get<bool>(parameter);
}
string Algorithm::getString(const string& name) const
string Algorithm::getString(const string& parameter) const
{
return get<string>(name);
return get<string>(parameter);
}
Mat Algorithm::getMat(const string& name) const
Mat Algorithm::getMat(const string& parameter) const
{
return get<Mat>(name);
return get<Mat>(parameter);
}
vector<Mat> Algorithm::getMatVector(const string& name) const
vector<Mat> Algorithm::getMatVector(const string& parameter) const
{
return get<vector<Mat> >(name);
return get<vector<Mat> >(parameter);
}
Ptr<Algorithm> Algorithm::getAlgorithm(const string& name) const
Ptr<Algorithm> Algorithm::getAlgorithm(const string& parameter) const
{
return get<Algorithm>(name);
return get<Algorithm>(parameter);
}
string Algorithm::paramHelp(const string& name) const
string Algorithm::paramHelp(const string& parameter) const
{
return info()->paramHelp(name.c_str());
return info()->paramHelp(parameter.c_str());
}
int Algorithm::paramType(const string& name) const
int Algorithm::paramType(const string& parameter) const
{
return info()->paramType(name.c_str());
return info()->paramType(parameter.c_str());
}
int Algorithm::paramType(const char* name) const
int Algorithm::paramType(const char* parameter) const
{
return info()->paramType(name);
return info()->paramType(parameter);
}
void Algorithm::getParams(vector<string>& names) const
@ -440,15 +440,15 @@ union GetSetParam
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
};
void AlgorithmInfo::set(Algorithm* algo, const char* name, int argType, const void* value, bool force) const
void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, const void* value, bool force) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
if( !force && p->readonly )
CV_Error_( CV_StsError, ("Parameter '%s' is readonly", name));
CV_Error_( CV_StsError, ("Parameter '%s' is readonly", parameter));
GetSetParam f;
f.set_int = p->setter;
@ -532,11 +532,11 @@ void AlgorithmInfo::set(Algorithm* algo, const char* name, int argType, const vo
CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type");
}
void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, void* value) const
void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argType, void* value) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
GetSetParam f;
f.get_int = p->getter;
@ -606,20 +606,20 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, vo
}
int AlgorithmInfo::paramType(const char* name) const
int AlgorithmInfo::paramType(const char* parameter) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
return p->type;
}
string AlgorithmInfo::paramHelp(const char* name) const
string AlgorithmInfo::paramHelp(const char* parameter) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
return p->help;
}
@ -630,7 +630,7 @@ void AlgorithmInfo::getParams(vector<string>& names) const
}
void AlgorithmInfo::addParam_(Algorithm& algo, const char* name, int argType,
void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType,
void* value, bool readOnly,
Algorithm::Getter getter, Algorithm::Setter setter,
const string& help)
@ -639,79 +639,79 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* name, int argType,
argType == Param::REAL || argType == Param::STRING ||
argType == Param::MAT || argType == Param::MAT_VECTOR ||
argType == Param::ALGORITHM );
data->params.add(string(name), Param(argType, readOnly,
data->params.add(string(parameter), Param(argType, readOnly,
(int)((size_t)value - (size_t)(void*)&algo),
getter, setter, help));
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
int& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
const string& help)
{
addParam_(algo, name, ParamType<int>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
bool& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
const string& help)
{
addParam_(algo, name, ParamType<bool>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
double& value, bool readOnly,
double (Algorithm::*getter)(),
void (Algorithm::*setter)(double),
const string& help)
{
addParam_(algo, name, ParamType<double>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<double>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
string& value, bool readOnly,
string (Algorithm::*getter)(),
void (Algorithm::*setter)(const string&),
const string& help)
{
addParam_(algo, name, ParamType<string>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<string>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Mat& value, bool readOnly,
Mat (Algorithm::*getter)(),
void (Algorithm::*setter)(const Mat&),
const string& help)
{
addParam_(algo, name, ParamType<Mat>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
vector<Mat>& value, bool readOnly,
vector<Mat> (Algorithm::*getter)(),
void (Algorithm::*setter)(const vector<Mat>&),
const string& help)
{
addParam_(algo, name, ParamType<vector<Mat> >::type, &value, readOnly,
addParam_(algo, parameter, ParamType<vector<Mat> >::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<Algorithm>& value, bool readOnly,
Ptr<Algorithm> (Algorithm::*getter)(),
void (Algorithm::*setter)(const Ptr<Algorithm>&),
const string& help)
{
addParam_(algo, name, ParamType<Algorithm>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}

View File

@ -335,8 +335,8 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
if( j + blocksize < total )
{
ptrs[0] += bsz*esz;
for( int k = 0; k < cn; k++ )
ptrs[k+1] += bsz*esz1;
for( int t = 0; t < cn; t++ )
ptrs[t+1] += bsz*esz1;
}
}
}
@ -489,12 +489,12 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
dsts[k] = ptrs[tab[k*4+2]] + tab[k*4+3];
}
for( int j = 0; j < total; j += blocksize )
for( int t = 0; t < total; t += blocksize )
{
int bsz = std::min(total - j, blocksize);
int bsz = std::min(total - t, blocksize);
func( srcs, sdelta, dsts, ddelta, bsz, (int)npairs );
if( j + blocksize < total )
if( t + blocksize < total )
for( k = 0; k < npairs; k++ )
{
srcs[k] += blocksize*sdelta[k]*esz1;
@ -628,28 +628,28 @@ cvtScale_<short, short, float>( const short* src, size_t sstep,
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_SSE2
if(USE_SSE2)
#if CV_SSE2
if(USE_SSE2)
{
__m128 scale128 = _mm_set1_ps (scale);
__m128 shift128 = _mm_set1_ps (shift);
for(; x <= size.width - 8; x += 8 )
{
__m128i r0 = _mm_loadl_epi64((const __m128i*)(src + x));
for(; x <= size.width - 8; x += 8 )
{
__m128i r0 = _mm_loadl_epi64((const __m128i*)(src + x));
__m128i r1 = _mm_loadl_epi64((const __m128i*)(src + x + 4));
__m128 rf0 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r0, r0), 16));
__m128 rf0 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r0, r0), 16));
__m128 rf1 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r1, r1), 16));
rf0 = _mm_add_ps(_mm_mul_ps(rf0, scale128), shift128);
rf1 = _mm_add_ps(_mm_mul_ps(rf1, scale128), shift128);
r0 = _mm_cvtps_epi32(rf0);
r1 = _mm_cvtps_epi32(rf1);
r0 = _mm_packs_epi32(r0, r1);
_mm_storeu_si128((__m128i*)(dst + x), r0);
}
}
r0 = _mm_cvtps_epi32(rf0);
r1 = _mm_cvtps_epi32(rf1);
r0 = _mm_packs_epi32(r0, r1);
_mm_storeu_si128((__m128i*)(dst + x), r0);
}
}
#endif
for(; x < size.width; x++ )
@ -668,17 +668,17 @@ cvt_( const T* src, size_t sstep,
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
DT t0, t1;
t0 = saturate_cast<DT>(src[x]);
t1 = saturate_cast<DT>(src[x+1]);
dst[x] = t0; dst[x+1] = t1;
t0 = saturate_cast<DT>(src[x+2]);
t1 = saturate_cast<DT>(src[x+3]);
dst[x+2] = t0; dst[x+3] = t1;
}
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
DT t0, t1;
t0 = saturate_cast<DT>(src[x]);
t1 = saturate_cast<DT>(src[x+1]);
dst[x] = t0; dst[x+1] = t1;
t0 = saturate_cast<DT>(src[x+2]);
t1 = saturate_cast<DT>(src[x+3]);
dst[x+2] = t0; dst[x+3] = t1;
}
#endif
for( ; x < size.width; x++ )
dst[x] = saturate_cast<DT>(src[x]);
@ -696,20 +696,20 @@ cvt_<float, short>( const float* src, size_t sstep,
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_SSE2
if(USE_SSE2){
for( ; x <= size.width - 8; x += 8 )
{
__m128 src128 = _mm_loadu_ps (src + x);
__m128i src_int128 = _mm_cvtps_epi32 (src128);
#if CV_SSE2
if(USE_SSE2){
for( ; x <= size.width - 8; x += 8 )
{
__m128 src128 = _mm_loadu_ps (src + x);
__m128i src_int128 = _mm_cvtps_epi32 (src128);
src128 = _mm_loadu_ps (src + x + 4);
__m128i src1_int128 = _mm_cvtps_epi32 (src128);
src128 = _mm_loadu_ps (src + x + 4);
__m128i src1_int128 = _mm_cvtps_epi32 (src128);
src1_int128 = _mm_packs_epi32(src_int128, src1_int128);
_mm_storeu_si128((__m128i*)(dst + x),src1_int128);
}
}
src1_int128 = _mm_packs_epi32(src_int128, src1_int128);
_mm_storeu_si128((__m128i*)(dst + x),src1_int128);
}
}
#endif
for( ; x < size.width; x++ )
dst[x] = saturate_cast<short>(src[x]);

View File

@ -59,7 +59,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, ucha
const T* src = (const T*)_src;
T* dst = (T*)_dst;
int x = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
if( mask[x] )
@ -193,10 +193,10 @@ void Mat::copyTo( OutputArray _dst ) const
const Mat* arrays[] = { this, &dst };
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs, 2);
size_t size = it.size*elemSize();
size_t sz = it.size*elemSize();
for( size_t i = 0; i < it.nplanes; i++, ++it )
memcpy(ptrs[1], ptrs[0], size);
memcpy(ptrs[1], ptrs[0], sz);
}
}
@ -242,14 +242,14 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
Mat& Mat::operator = (const Scalar& s)
{
const Mat* arrays[] = { this };
uchar* ptr;
NAryMatIterator it(arrays, &ptr, 1);
size_t size = it.size*elemSize();
uchar* dptr;
NAryMatIterator it(arrays, &dptr, 1);
size_t elsize = it.size*elemSize();
if( s[0] == 0 && s[1] == 0 && s[2] == 0 && s[3] == 0 )
{
for( size_t i = 0; i < it.nplanes; i++, ++it )
memset( ptr, 0, size );
memset( dptr, 0, elsize );
}
else
{
@ -259,17 +259,17 @@ Mat& Mat::operator = (const Scalar& s)
scalarToRawData(s, scalar, type(), 12);
size_t blockSize = 12*elemSize1();
for( size_t j = 0; j < size; j += blockSize )
for( size_t j = 0; j < elsize; j += blockSize )
{
size_t sz = MIN(blockSize, size - j);
memcpy( ptr + j, scalar, sz );
size_t sz = MIN(blockSize, elsize - j);
memcpy( dptr + j, scalar, sz );
}
}
for( size_t i = 1; i < it.nplanes; i++ )
{
++it;
memcpy( ptr, data, size );
memcpy( dptr, data, elsize );
}
}
return *this;
@ -292,16 +292,16 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
const Mat* arrays[] = { this, !mask.empty() ? &mask : 0, 0 };
uchar* ptrs[2]={0,0};
NAryMatIterator it(arrays, ptrs);
int total = (int)it.size, blockSize0 = std::min(total, (int)((BLOCK_SIZE + esz-1)/esz));
int totalsz = (int)it.size, blockSize0 = std::min(totalsz, (int)((BLOCK_SIZE + esz-1)/esz));
AutoBuffer<uchar> _scbuf(blockSize0*esz + 32);
uchar* scbuf = alignPtr((uchar*)_scbuf, (int)sizeof(double));
convertAndUnrollScalar( value, type(), scbuf, blockSize0 );
for( size_t i = 0; i < it.nplanes; i++, ++it )
{
for( int j = 0; j < total; j += blockSize0 )
for( int j = 0; j < totalsz; j += blockSize0 )
{
Size sz(std::min(blockSize0, total - j), 1);
Size sz(std::min(blockSize0, totalsz - j), 1);
size_t blockSize = sz.width*esz;
if( ptrs[1] )
{

View File

@ -3653,7 +3653,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
points.create(_points.size(), _points.type());
}
int i, j, n = _points.rows, dims = _points.cols, top = 0;
int i, j, n = _points.rows, ptdims = _points.cols, top = 0;
const float* data = _points.ptr<float>(0);
float* dstdata = points.ptr<float>(0);
size_t step = _points.step1();
@ -3669,7 +3669,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
_labels_data = (const int*)_labels.data;
}
Mat sumstack(MAX_TREE_DEPTH*2, dims*2, CV_64F);
Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F);
SubTree stack[MAX_TREE_DEPTH*2];
vector<size_t> _ptofs(n);
@ -3700,7 +3700,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
{
const float* src = data + ptofs[first];
float* dst = dstdata + idx*dstep;
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
dst[j] = src[j];
}
labels[idx] = _labels_data ? _labels_data[idx0] : idx0;
@ -3709,7 +3709,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
}
// find the dimensionality with the biggest variance
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
{
double m = sums[j*2]*invCount;
double varj = sums[j*2+1]*invCount - m*m;
@ -3729,9 +3729,9 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
nodes[nidx].boundary = medianPartition(ptofs, first, last, data + dim);
int middle = (first + last)/2;
double *lsums = (double*)sums, *rsums = lsums + dims*2;
double *lsums = (double*)sums, *rsums = lsums + ptdims*2;
computeSums(points, ptofs, middle+1, last, rsums);
for( j = 0; j < dims*2; j++ )
for( j = 0; j < ptdims*2; j++ )
lsums[j] = sums[j] - rsums[j];
stack[top++] = SubTree(first, middle, left, depth+1);
stack[top++] = SubTree(middle+1, last, right, depth+1);
@ -3758,7 +3758,7 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
CV_Assert( vecmat.isContinuous() && vecmat.type() == CV_32F && vecmat.total() == (size_t)points.cols );
const float* vec = vecmat.ptr<float>();
K = std::min(K, points.rows);
int dims = points.cols;
int ptdims = points.cols;
CV_Assert(K > 0 && (normType == NORM_L2 || normType == NORM_L1));
@ -3819,13 +3819,13 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
i = ~n.idx;
const float* row = points.ptr<float>(i);
if( normType == NORM_L2 )
for( j = 0, d = 0.f; j < dims; j++ )
for( j = 0, d = 0.f; j < ptdims; j++ )
{
float t = vec[j] - row[j];
d += t*t;
}
else
for( j = 0, d = 0.f; j < dims; j++ )
for( j = 0, d = 0.f; j < ptdims; j++ )
d += std::abs(vec[j] - row[j]);
dist[ncount] = d;
@ -3898,14 +3898,14 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
OutputArray _neighbors,
OutputArray _labels ) const
{
int dims = points.cols;
int ptdims = points.cols;
Mat lowerBound = _lowerBound.getMat(), upperBound = _upperBound.getMat();
CV_Assert( lowerBound.size == upperBound.size &&
lowerBound.isContinuous() &&
upperBound.isContinuous() &&
lowerBound.type() == upperBound.type() &&
lowerBound.type() == CV_32F &&
lowerBound.total() == (size_t)dims );
lowerBound.total() == (size_t)ptdims );
const float* L = lowerBound.ptr<float>();
const float* R = upperBound.ptr<float>();
@ -3926,10 +3926,10 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
{
int j, i = ~n.idx;
const float* row = points.ptr<float>(i);
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
if( row[j] < L[j] || row[j] >= R[j] )
break;
if( j == dims )
if( j == ptdims )
idx.push_back(i);
continue;
}
@ -3957,7 +3957,7 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
const int* idx = idxmat.ptr<int>();
int* dstlabels = 0;
int dims = points.cols;
int ptdims = points.cols;
int i, nidx = (int)idxmat.total();
if( nidx == 0 )
{
@ -3968,7 +3968,7 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
if( _pts.needed() )
{
_pts.create( nidx, dims, points.type());
_pts.create( nidx, ptdims, points.type());
pts = _pts.getMat();
}
@ -3987,7 +3987,7 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
CV_Assert( (unsigned)k < (unsigned)points.rows );
const float* src = points.ptr<float>(k);
if( pts.data )
std::copy(src, src + dims, pts.ptr<float>(i));
std::copy(src, src + ptdims, pts.ptr<float>(i));
if( dstlabels )
dstlabels[i] = srclabels ? srclabels[k] : k;
}

View File

@ -169,7 +169,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
}
int bt_pix0 = (int)img.elemSize(), bt_pix = bt_pix0;
size_t step = img.step;
size_t istep = img.step;
int dx = pt2.x - pt1.x;
int dy = pt2.y - pt1.y;
@ -188,11 +188,11 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
bt_pix = (bt_pix ^ s) - s;
}
ptr = (uchar*)(img.data + pt1.y * step + pt1.x * bt_pix0);
ptr = (uchar*)(img.data + pt1.y * istep + pt1.x * bt_pix0);
s = dy < 0 ? -1 : 0;
dy = (dy ^ s) - s;
step = (step ^ s) - s;
istep = (istep ^ s) - s;
s = dy > dx ? -1 : 0;
@ -201,9 +201,9 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
dy ^= dx & s;
dx ^= dy & s;
bt_pix ^= step & s;
step ^= bt_pix & s;
bt_pix ^= step & s;
bt_pix ^= istep & s;
istep ^= bt_pix & s;
bt_pix ^= istep & s;
if( connectivity == 8 )
{
@ -212,7 +212,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
err = dx - (dy + dy);
plusDelta = dx + dx;
minusDelta = -(dy + dy);
plusStep = (int)step;
plusStep = (int)istep;
minusStep = bt_pix;
count = dx + 1;
}
@ -223,7 +223,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
err = 0;
plusDelta = (dx + dx) + (dy + dy);
minusDelta = -(dy + dy);
plusStep = (int)step - bt_pix;
plusStep = (int)istep - bt_pix;
minusStep = bt_pix;
count = dx + dy + 1;
}

View File

@ -524,30 +524,30 @@ cv::gpu::GpuMat::GpuMat(Size size_, int type_, void* data_, size_t step_) :
dataend += step * (rows - 1) + minstep;
}
cv::gpu::GpuMat::GpuMat(const GpuMat& m, Range rowRange, Range colRange)
cv::gpu::GpuMat::GpuMat(const GpuMat& m, Range _rowRange, Range _colRange)
{
flags = m.flags;
step = m.step; refcount = m.refcount;
data = m.data; datastart = m.datastart; dataend = m.dataend;
if (rowRange == Range::all())
if (_rowRange == Range::all())
rows = m.rows;
else
{
CV_Assert(0 <= rowRange.start && rowRange.start <= rowRange.end && rowRange.end <= m.rows);
CV_Assert(0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows);
rows = rowRange.size();
data += step*rowRange.start;
rows = _rowRange.size();
data += step*_rowRange.start;
}
if (colRange == Range::all())
if (_colRange == Range::all())
cols = m.cols;
else
{
CV_Assert(0 <= colRange.start && colRange.start <= colRange.end && colRange.end <= m.cols);
CV_Assert(0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols);
cols = colRange.size();
data += colRange.start*elemSize();
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~Mat::CONTINUOUS_FLAG : -1;
}

View File

@ -63,7 +63,7 @@ GEMM_CopyBlock( const uchar* src, size_t src_step,
for( ; size.height--; src += src_step, dst += dst_step )
{
j=0;
j=0;
#if CV_ENABLE_UNROLLED
for( ; j <= size.width - 4; j += 4 )
{
@ -345,7 +345,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
for( k = 0; k < n; k++, b_data += b_step )
{
WT al(a_data[k]);
j=0;
j=0;
#if CV_ENABLE_UNROLLED
for(; j <= m - 4; j += 4 )
{
@ -513,8 +513,8 @@ GEMMStore( const T* c_data, size_t c_step,
if( _c_data )
{
c_data = _c_data;
j=0;
#if CV_ENABLE_UNROLLED
j=0;
#if CV_ENABLE_UNROLLED
for(; j <= d_size.width - 4; j += 4, c_data += 4*c_step1 )
{
WT t0 = alpha*d_buf[j];
@ -539,8 +539,8 @@ GEMMStore( const T* c_data, size_t c_step,
}
else
{
j = 0;
#if CV_ENABLE_UNROLLED
j = 0;
#if CV_ENABLE_UNROLLED
for( ; j <= d_size.width - 4; j += 4 )
{
WT t0 = alpha*d_buf[j];
@ -552,7 +552,7 @@ GEMMStore( const T* c_data, size_t c_step,
d_data[j+2] = T(t0);
d_data[j+3] = T(t1);
}
#endif
#endif
for( ; j < d_size.width; j++ )
d_data[j] = T(alpha*d_buf[j]);
}
@ -696,7 +696,7 @@ static void GEMMStore_64fc( const Complexd* c_data, size_t c_step,
}
void cv::gemm( InputArray matA, InputArray matB, double alpha,
InputArray matC, double beta, OutputArray matD, int flags )
InputArray matC, double beta, OutputArray _matD, int flags )
{
const int block_lin_size = 128;
const int block_size = block_lin_size * block_lin_size;
@ -741,8 +741,8 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
((flags&GEMM_3_T) != 0 && C.rows == d_size.width && C.cols == d_size.height)));
}
matD.create( d_size.height, d_size.width, type );
Mat D = matD.getMat();
_matD.create( d_size.height, d_size.width, type );
Mat D = _matD.getMat();
if( (flags & GEMM_3_T) != 0 && C.data == D.data )
{
transpose( C, C );
@ -2008,7 +2008,7 @@ static void scaleAdd_32f(const float* src1, const float* src2, float* dst,
t1 = src1[i+3]*alpha + src2[i+3];
dst[i+2] = t0; dst[i+3] = t1;
}
for(; i < len; i++ )
for(; i < len; i++ )
dst[i] = src1[i]*alpha + src2[i];
}
@ -2046,7 +2046,7 @@ static void scaleAdd_64f(const double* src1, const double* src2, double* dst,
t1 = src1[i+3]*alpha + src2[i+3];
dst[i+2] = t0; dst[i+3] = t1;
}
for(; i < len; i++ )
for(; i < len; i++ )
dst[i] = src1[i]*alpha + src2[i];
}
@ -2134,12 +2134,12 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean,
_mean = mean.reshape(1, size.height);
}
void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray _mean, int flags, int ctype )
void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, int ctype )
{
if(_data.kind() == _InputArray::STD_VECTOR_MAT)
if(_src.kind() == _InputArray::STD_VECTOR_MAT)
{
std::vector<cv::Mat> src;
_data.getMatVector(src);
_src.getMatVector(src);
CV_Assert( src.size() > 0 );
@ -2185,7 +2185,7 @@ void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray
return;
}
Mat data = _data.getMat(), mean;
Mat data = _src.getMat(), mean;
CV_Assert( ((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0) );
bool takeRows = (flags & CV_COVAR_ROWS) != 0;
int type = data.type();
@ -2209,7 +2209,7 @@ void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray
else
{
ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F);
reduce( _data, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
mean = _mean.getMat();
}
@ -2261,7 +2261,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
{
double row_sum = 0;
j = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for(; j <= len - 4; j += 4 )
row_sum += diff[j]*mat[j] + diff[j+1]*mat[j+1] +
diff[j+2]*mat[j+2] + diff[j+3]*mat[j+3];
@ -2292,7 +2292,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
{
double row_sum = 0;
j = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for(; j <= len - 4; j += 4 )
row_sum += diff[j]*mat[j] + diff[j+1]*mat[j+1] +
diff[j+2]*mat[j+2] + diff[j+3]*mat[j+3];
@ -2642,7 +2642,7 @@ dotProd_(const T* src1, const T* src2, int len)
{
int i = 0;
double result = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
result += (double)src1[i]*src2[i] + (double)src1[i+1]*src2[i+1] +
(double)src1[i+2]*src2[i+2] + (double)src1[i+3]*src2[i+3];
@ -2674,7 +2674,7 @@ static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
{
blockSize = std::min(len0 - i, blockSize0);
__m128i s = _mm_setzero_si128();
j = 0;
j = 0;
for( ; j <= blockSize - 16; j += 16 )
{
__m128i b0 = _mm_loadu_si128((const __m128i*)(src1 + j));
@ -2806,9 +2806,9 @@ double Mat::dot(InputArray _mat) const
PCA::PCA() {}
PCA::PCA(InputArray data, InputArray mean, int flags, int maxComponents)
PCA::PCA(InputArray data, InputArray _mean, int flags, int maxComponents)
{
operator()(data, mean, flags, maxComponents);
operator()(data, _mean, flags, maxComponents);
}
PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComponents)

View File

@ -1181,14 +1181,14 @@ int MatExpr::type() const
/////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Identity::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Identity::assign(const MatExpr& e, Mat& m, int _type) const
{
if( type == -1 || type == e.a.type() )
if( _type == -1 || _type == e.a.type() )
m = e.a;
else
{
CV_Assert( CV_MAT_CN(type) == e.a.channels() );
e.a.convertTo(m, type);
CV_Assert( CV_MAT_CN(_type) == e.a.channels() );
e.a.convertTo(m, _type);
}
}
@ -1199,9 +1199,9 @@ inline void MatOp_Identity::makeExpr(MatExpr& res, const Mat& m)
/////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || e.a.type() == type ? m : temp;
Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp;
if( e.b.data )
{
if( e.s == Scalar() || !e.s.isReal() )
@ -1233,7 +1233,7 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int type) const
}
else if( e.s.isReal() && (dst.data != m.data || fabs(e.alpha) != 1))
{
e.a.convertTo(m, type, e.alpha, e.s[0]);
e.a.convertTo(m, _type, e.alpha, e.s[0]);
return;
}
else if( e.alpha == 1 )
@ -1308,9 +1308,9 @@ inline void MatOp_AddEx::makeExpr(MatExpr& res, const Mat& a, const Mat& b, doub
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Bin::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || e.a.type() == type ? m : temp;
Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp;
if( e.flags == '*' )
cv::multiply(e.a, e.b, dst, e.alpha);
@ -1348,7 +1348,7 @@ void MatOp_Bin::assign(const MatExpr& e, Mat& m, int type) const
CV_Error(CV_StsError, "Unknown operation");
if( dst.data != m.data )
dst.convertTo(m, type);
dst.convertTo(m, _type);
}
void MatOp_Bin::multiply(const MatExpr& e, double s, MatExpr& res) const
@ -1382,9 +1382,9 @@ inline void MatOp_Bin::makeExpr(MatExpr& res, char op, const Mat& a, const Scala
///////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || type == CV_8U ? m : temp;
Mat temp, &dst = _type == -1 || _type == CV_8U ? m : temp;
if( e.b.data )
cv::compare(e.a, e.b, dst, e.flags);
@ -1392,7 +1392,7 @@ void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int type) const
cv::compare(e.a, e.alpha, dst, e.flags);
if( dst.data != m.data )
dst.convertTo(m, type);
dst.convertTo(m, _type);
}
inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b)
@ -1407,14 +1407,14 @@ inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, double al
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_T::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_T::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || type == e.a.type() ? m : temp;
Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp;
cv::transpose(e.a, dst);
if( dst.data != m.data || e.alpha != 1 )
dst.convertTo(m, type, e.alpha);
dst.convertTo(m, _type, e.alpha);
}
void MatOp_T::multiply(const MatExpr& e, double s, MatExpr& res) const
@ -1438,13 +1438,13 @@ inline void MatOp_T::makeExpr(MatExpr& res, const Mat& a, double alpha)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_GEMM::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_GEMM::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || type == e.a.type() ? m : temp;
Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp;
cv::gemm(e.a, e.b, e.alpha, e.c, e.beta, dst, e.flags);
if( dst.data != m.data )
dst.convertTo(m, type);
dst.convertTo(m, _type);
}
void MatOp_GEMM::add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const
@ -1503,13 +1503,13 @@ inline void MatOp_GEMM::makeExpr(MatExpr& res, int flags, const Mat& a, const Ma
///////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Invert::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Invert::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || type == e.a.type() ? m : temp;
Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp;
cv::invert(e.a, dst, e.flags);
if( dst.data != m.data )
dst.convertTo(m, type);
dst.convertTo(m, _type);
}
void MatOp_Invert::matmul(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const
@ -1529,13 +1529,13 @@ inline void MatOp_Invert::makeExpr(MatExpr& res, int method, const Mat& m)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Solve::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Solve::assign(const MatExpr& e, Mat& m, int _type) const
{
Mat temp, &dst = type == -1 || type == e.a.type() ? m : temp;
Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp;
cv::solve(e.a, e.b, dst, e.flags);
if( dst.data != m.data )
dst.convertTo(m, type);
dst.convertTo(m, _type);
}
inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b)
@ -1545,11 +1545,11 @@ inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int type) const
void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const
{
if( type == -1 )
type = e.a.type();
m.create(e.a.size(), type);
if( _type == -1 )
_type = e.a.type();
m.create(e.a.size(), _type);
if( e.flags == 'I' )
setIdentity(m, Scalar(e.alpha));
else if( e.flags == '0' )

View File

@ -210,9 +210,9 @@ void Mat::create(int d, const int* _sizes, int _type)
#endif
if( !allocator )
{
size_t total = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
data = datastart = (uchar*)fastMalloc(total + (int)sizeof(*refcount));
refcount = (int*)(data + total);
size_t totalsize = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
data = datastart = (uchar*)fastMalloc(totalsize + (int)sizeof(*refcount));
refcount = (int*)(data + totalsize);
*refcount = 1;
}
else
@ -262,15 +262,15 @@ void Mat::deallocate()
}
Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange) : size(&rows)
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) : size(&rows)
{
initEmpty();
CV_Assert( m.dims >= 2 );
if( m.dims > 2 )
{
AutoBuffer<Range> rs(m.dims);
rs[0] = rowRange;
rs[1] = colRange;
rs[0] = _rowRange;
rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all();
*this = m(rs);
@ -278,19 +278,19 @@ Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange) : size(&row
}
*this = m;
if( rowRange != Range::all() && rowRange != Range(0,rows) )
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
CV_Assert( 0 <= rowRange.start && rowRange.start <= rowRange.end && rowRange.end <= m.rows );
rows = rowRange.size();
data += step*rowRange.start;
CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows );
rows = _rowRange.size();
data += step*_rowRange.start;
flags |= SUBMATRIX_FLAG;
}
if( colRange != Range::all() && colRange != Range(0,cols) )
if( _colRange != Range::all() && _colRange != Range(0,cols) )
{
CV_Assert( 0 <= colRange.start && colRange.start <= colRange.end && colRange.end <= m.cols );
cols = colRange.size();
data += colRange.start*elemSize();
CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols );
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~CONTINUOUS_FLAG : -1;
flags |= SUBMATRIX_FLAG;
}
@ -473,14 +473,14 @@ Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
dims = 2;
CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0);
int depth = IPL2CV_DEPTH(img->depth);
int imgdepth = IPL2CV_DEPTH(img->depth);
size_t esz;
step[0] = img->widthStep;
if(!img->roi)
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL);
flags = MAGIC_VAL + CV_MAKETYPE(depth, img->nChannels);
flags = MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels);
rows = img->height; cols = img->width;
datastart = data = (uchar*)img->imageData;
esz = CV_ELEM_SIZE(flags);
@ -489,7 +489,7 @@ Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0);
bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE;
flags = MAGIC_VAL + CV_MAKETYPE(depth, selectedPlane ? 1 : img->nChannels);
flags = MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels);
rows = img->roi->height; cols = img->roi->width;
esz = CV_ELEM_SIZE(flags);
data = datastart = (uchar*)img->imageData +
@ -1299,38 +1299,38 @@ bool _OutputArray::fixedType() const
return (flags & FIXED_TYPE) == FIXED_TYPE;
}
void _OutputArray::create(Size _sz, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == _sz);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == type);
((Mat*)obj)->create(_sz, type);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == mtype);
((Mat*)obj)->create(_sz, mtype);
return;
}
int sz[] = {_sz.height, _sz.width};
create(2, sz, type, i, allowTransposed, fixedDepthMask);
int sizes[] = {_sz.height, _sz.width};
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
}
void _OutputArray::create(int rows, int cols, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == Size(cols, rows));
CV_Assert(!fixedType() || ((Mat*)obj)->type() == type);
((Mat*)obj)->create(rows, cols, type);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == mtype);
((Mat*)obj)->create(rows, cols, mtype);
return;
}
int sz[] = {rows, cols};
create(2, sz, type, i, allowTransposed, fixedDepthMask);
int sizes[] = {rows, cols};
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
}
void _OutputArray::create(int dims, const int* size, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
type = CV_MAT_TYPE(type);
mtype = CV_MAT_TYPE(mtype);
if( k == MAT )
{
@ -1345,24 +1345,24 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
}
if( dims == 2 && m.dims == 2 && m.data &&
m.type() == type && m.rows == size[1] && m.cols == size[0] )
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
}
if(fixedType())
{
if(CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
type = m.type();
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(CV_MAT_TYPE(type) == m.type());
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
}
if(fixedSize())
{
CV_Assert(m.dims == dims);
for(int j = 0; j < dims; ++j)
CV_Assert(m.size[j] == size[j]);
CV_Assert(m.size[j] == sizes[j]);
}
m.create(dims, size, type);
m.create(dims, sizes, mtype);
return;
}
@ -1370,16 +1370,16 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
{
CV_Assert( i < 0 );
int type0 = CV_MAT_TYPE(flags);
CV_Assert( type == type0 || (CV_MAT_CN(type) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( dims == 2 && ((size[0] == sz.height && size[1] == sz.width) ||
(allowTransposed && size[0] == sz.width && size[1] == sz.height)));
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( dims == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) ||
(allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height)));
return;
}
if( k == STD_VECTOR || k == STD_VECTOR_VECTOR )
{
CV_Assert( dims == 2 && (size[0] == 1 || size[1] == 1 || size[0]*size[1] == 0) );
size_t len = size[0]*size[1] > 0 ? size[0] + size[1] - 1 : 0;
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0;
vector<uchar>* v = (vector<uchar>*)obj;
if( k == STD_VECTOR_VECTOR )
@ -1398,7 +1398,7 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
CV_Assert( i < 0 );
int type0 = CV_MAT_TYPE(flags);
CV_Assert( type == type0 || (CV_MAT_CN(type) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
int esz = CV_ELEM_SIZE(type0);
CV_Assert(!fixedSize() || len == ((vector<uchar>*)v)->size() / esz);
@ -1471,20 +1471,20 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
if( i < 0 )
{
CV_Assert( dims == 2 && (size[0] == 1 || size[1] == 1 || size[0]*size[1] == 0) );
size_t len = size[0]*size[1] > 0 ? size[0] + size[1] - 1 : 0, len0 = v.size();
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0, len0 = v.size();
CV_Assert(!fixedSize() || len == len0);
v.resize(len);
if( fixedType() )
{
int type = CV_MAT_TYPE(flags);
int _type = CV_MAT_TYPE(flags);
for( size_t j = len0; j < len; j++ )
{
if( v[i].type() == type )
if( v[i].type() == _type )
continue;
CV_Assert( v[i].empty() );
v[i].flags = (v[i].flags & ~CV_MAT_TYPE_MASK) | type;
v[i].flags = (v[i].flags & ~CV_MAT_TYPE_MASK) | _type;
}
}
return;
@ -1502,25 +1502,25 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
}
if( dims == 2 && m.dims == 2 && m.data &&
m.type() == type && m.rows == size[1] && m.cols == size[0] )
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
}
if(fixedType())
{
if(CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
type = m.type();
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(!fixedType() || (CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0));
CV_Assert(!fixedType() || (CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0));
}
if(fixedSize())
{
CV_Assert(m.dims == dims);
for(int j = 0; j < dims; ++j)
CV_Assert(m.size[j] == size[j]);
CV_Assert(m.size[j] == sizes[j]);
}
m.create(dims, size, type);
m.create(dims, sizes, mtype);
}
}
@ -1929,10 +1929,10 @@ void cv::completeSymm( InputOutputArray _m, bool LtoR )
cv::Mat cv::Mat::cross(InputArray _m) const
{
Mat m = _m.getMat();
int t = type(), d = CV_MAT_DEPTH(t);
CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && t == m.type() &&
int tp = type(), d = CV_MAT_DEPTH(tp);
CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && tp == m.type() &&
((rows == 3 && cols == 1) || (cols*channels() == 3 && rows == 1)));
Mat result(rows, cols, t);
Mat result(rows, cols, tp);
if( d == CV_32F )
{
@ -2845,7 +2845,7 @@ cvRange( CvArr* arr, double start, double end )
CV_IMPL void
cvSort( const CvArr* _src, CvArr* _dst, CvArr* _idx, int flags )
{
cv::Mat src = cv::cvarrToMat(_src), dst, idx;
cv::Mat src = cv::cvarrToMat(_src);
if( _idx )
{
@ -3410,22 +3410,22 @@ SparseMat::SparseMat(const Mat& m)
int i, idx[CV_MAX_DIM] = {0}, d = m.dims, lastSize = m.size[d - 1];
size_t esz = m.elemSize();
uchar* ptr = m.data;
uchar* dptr = m.data;
for(;;)
{
for( i = 0; i < lastSize; i++, ptr += esz )
for( i = 0; i < lastSize; i++, dptr += esz )
{
if( isZeroElem(ptr, esz) )
if( isZeroElem(dptr, esz) )
continue;
idx[d-1] = i;
uchar* to = newNode(idx, hash(idx));
copyElem( ptr, to, esz );
copyElem( dptr, to, esz );
}
for( i = d - 2; i >= 0; i-- )
{
ptr += m.step[i] - m.size[i+1]*m.step[i+1];
dptr += m.step[i] - m.size[i+1]*m.step[i+1];
if( ++idx[i] < m.size[i] )
break;
idx[i] = 0;

View File

@ -163,11 +163,11 @@ void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab)
void cv::gpu::setGlDevice(int device)
{
#ifndef HAVE_CUDA
(void)device;
(void)device;
throw_nocuda;
#else
#ifndef HAVE_OPENGL
(void)device;
(void)device;
throw_nogl;
#else
if (!glFuncTab()->isGlContextInitialized())
@ -484,57 +484,57 @@ inline void cv::GlBuffer::Impl::unmapDevice(cudaStream_t stream)
#endif // HAVE_OPENGL
cv::GlBuffer::GlBuffer(Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)usage;
(void)_usage;
throw_nogl;
#else
impl_ = Impl::empty();
#endif
}
cv::GlBuffer::GlBuffer(int rows, int cols, int type, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(int _rows, int _cols, int _type, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)usage;
(void)_rows;
(void)_cols;
(void)_type;
(void)_usage;
throw_nogl;
#else
impl_ = new Impl(rows, cols, type, usage);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type, _usage);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
#endif
}
cv::GlBuffer::GlBuffer(Size size, int type, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(Size _size, int _type, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)size;
(void)type;
(void)usage;
(void)_size;
(void)_type;
(void)_usage;
throw_nogl;
#else
impl_ = new Impl(size.height, size.width, type, usage);
rows_ = size.height;
cols_ = size.width;
type_ = type;
impl_ = new Impl(_size.height, _size.width, _type, _usage);
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
cv::GlBuffer::GlBuffer(InputArray mat_, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(InputArray mat_, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)usage;
(void)mat_;
(void)_usage;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
if (kind == _InputArray::GPU_MAT)
{
@ -542,38 +542,38 @@ cv::GlBuffer::GlBuffer(InputArray mat_, Usage usage) : rows_(0), cols_(0), type_
throw_nocuda;
#else
GpuMat d_mat = mat_.getGpuMat();
impl_ = new Impl(d_mat.rows, d_mat.cols, d_mat.type(), usage);
impl_ = new Impl(d_mat.rows, d_mat.cols, d_mat.type(), _usage);
impl_->copyFrom(d_mat);
#endif
}
else
{
Mat mat = mat_.getMat();
impl_ = new Impl(mat, usage);
impl_ = new Impl(mat, _usage);
}
rows_ = size.height;
cols_ = size.width;
type_ = type;
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
void cv::GlBuffer::create(int rows, int cols, int type, Usage usage)
void cv::GlBuffer::create(int _rows, int _cols, int _type, Usage _usage)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)usage;
(void)_rows;
(void)_cols;
(void)_type;
(void)_usage;
throw_nogl;
#else
if (rows_ != rows || cols_ != cols || type_ != type || usage_ != usage)
if (rows_ != _rows || cols_ != _cols || type_ != _type || usage_ != _usage)
{
impl_ = new Impl(rows, cols, type, usage);
rows_ = rows;
cols_ = cols;
type_ = type;
usage_ = usage;
impl_ = new Impl(_rows, _cols, _type, _usage);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
usage_ = _usage;
}
#endif
}
@ -590,14 +590,14 @@ void cv::GlBuffer::release()
void cv::GlBuffer::copyFrom(InputArray mat_)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)mat_;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
create(size, type);
create(_size, _type);
switch (kind)
{
@ -926,45 +926,45 @@ cv::GlTexture::GlTexture() : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTUR
#endif
}
cv::GlTexture::GlTexture(int rows, int cols, int type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
cv::GlTexture::GlTexture(int _rows, int _cols, int _type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)_rows;
(void)_cols;
(void)_type;
throw_nogl;
#else
impl_ = new Impl(rows, cols, type);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
#endif
}
cv::GlTexture::GlTexture(Size size, int type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
cv::GlTexture::GlTexture(Size _size, int _type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)size;
(void)type;
(void)_size;
(void)_type;
throw_nogl;
#else
impl_ = new Impl(size.height, size.width, type);
rows_ = size.height;
cols_ = size.width;
type_ = type;
impl_ = new Impl(_size.height, _size.width, _type);
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
cv::GlTexture::GlTexture(InputArray mat_, bool bgra) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)bgra;
(void)mat_;
(void)bgra;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
switch (kind)
{
@ -994,26 +994,26 @@ cv::GlTexture::GlTexture(InputArray mat_, bool bgra) : rows_(0), cols_(0), type_
}
}
rows_ = size.height;
cols_ = size.width;
type_ = type;
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
void cv::GlTexture::create(int rows, int cols, int type)
void cv::GlTexture::create(int _rows, int _cols, int _type)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)_rows;
(void)_cols;
(void)_type;
throw_nogl;
#else
if (rows_ != rows || cols_ != cols || type_ != type)
if (rows_ != _rows || cols_ != _cols || type_ != _type)
{
impl_ = new Impl(rows, cols, type);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
}
#endif
}
@ -1030,15 +1030,15 @@ void cv::GlTexture::release()
void cv::GlTexture::copyFrom(InputArray mat_, bool bgra)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)bgra;
(void)mat_;
(void)bgra;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
create(size, type);
create(_size, _type);
switch(kind)
{
@ -1244,8 +1244,8 @@ void cv::GlArrays::unbind() const
////////////////////////////////////////////////////////////////////////
// GlFont
cv::GlFont::GlFont(const string& family, int height, Weight weight, Style style)
: family_(family), height_(height), weight_(weight), style_(style), base_(0)
cv::GlFont::GlFont(const string& _family, int _height, Weight _weight, Style _style)
: family_(_family), height_(_height), weight_(_weight), style_(_style), base_(0)
{
#ifndef HAVE_OPENGL
throw_nogl;
@ -1253,7 +1253,7 @@ cv::GlFont::GlFont(const string& family, int height, Weight weight, Style style)
base_ = glGenLists(256);
CV_CheckGlError();
glFuncTab()->generateBitmapFont(family, height, weight, (style & STYLE_ITALIC) != 0, (style & STYLE_UNDERLINE) != 0, 0, 256, base_);
glFuncTab()->generateBitmapFont(family_, height_, weight_, (style_ & STYLE_ITALIC) != 0, (style_ & STYLE_UNDERLINE) != 0, 0, 256, base_);
#endif
}
@ -1304,10 +1304,10 @@ namespace
Ptr<GlFont> cv::GlFont::get(const std::string& family, int height, Weight weight, Style style)
{
#ifndef HAVE_OPENGL
(void)family;
(void)height;
(void)weight;
(void)style;
(void)family;
(void)height;
(void)weight;
(void)style;
throw_nogl;
return Ptr<GlFont>();
#else
@ -1333,9 +1333,9 @@ Ptr<GlFont> cv::GlFont::get(const std::string& family, int height, Weight weight
void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRect)
{
#ifndef HAVE_OPENGL
(void)tex;
(void)wndRect;
(void)texRect;
(void)tex;
(void)wndRect;
(void)texRect;
throw_nogl;
#else
if (!tex.empty())
@ -1368,9 +1368,9 @@ void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRe
void cv::render(const GlArrays& arr, int mode, Scalar color)
{
#ifndef HAVE_OPENGL
(void)arr;
(void)mode;
(void)color;
(void)arr;
(void)mode;
(void)color;
throw_nogl;
#else
glColor3d(color[0] / 255.0, color[1] / 255.0, color[2] / 255.0);
@ -1386,10 +1386,10 @@ void cv::render(const GlArrays& arr, int mode, Scalar color)
void cv::render(const string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos)
{
#ifndef HAVE_OPENGL
(void)str;
(void)font;
(void)color;
(void)pos;
(void)str;
(void)font;
(void)color;
(void)pos;
throw_nogl;
#else
glPushAttrib(GL_DEPTH_BUFFER_BIT);
@ -1544,9 +1544,9 @@ void cv::GlCamera::setupModelViewMatrix() const
bool icvCheckGlError(const char* file, const int line, const char* func)
{
#ifndef HAVE_OPENGL
(void)file;
(void)line;
(void)func;
(void)file;
(void)line;
(void)func;
return true;
#else
GLenum err = glGetError();

View File

@ -1262,7 +1262,7 @@ int Core_SetTest::test_set_ops( int iters )
if( iter > iters/10 && cvtest::randInt(rng)%200 == 0 ) // clear set
{
int prev_count = cvset->total;
prev_count = cvset->total;
cvClearSet( cvset );
cvTsClearSimpleSet( sset );
@ -1482,19 +1482,19 @@ int Core_GraphTest::test_graph_ops( int iters )
if( cvtest::randInt(rng) % 200 == 0 ) // clear graph
{
int prev_vtx_count = graph->total, prev_edge_count = graph->edges->total;
int prev_vtx_count2 = graph->total, prev_edge_count2 = graph->edges->total;
cvClearGraph( graph );
cvTsClearSimpleGraph( sgraph );
CV_TS_SEQ_CHECK_CONDITION( graph->active_count == 0 && graph->total == 0 &&
graph->first == 0 && graph->free_elems == 0 &&
(graph->free_blocks != 0 || prev_vtx_count == 0),
(graph->free_blocks != 0 || prev_vtx_count2 == 0),
"The graph is not empty after clearing" );
CV_TS_SEQ_CHECK_CONDITION( edges->active_count == 0 && edges->total == 0 &&
edges->first == 0 && edges->free_elems == 0 &&
(edges->free_blocks != 0 || prev_edge_count == 0),
(edges->free_blocks != 0 || prev_edge_count2 == 0),
"The graph is not empty after clearing" );
}
else if( op == 0 ) // add vertex

View File

@ -284,8 +284,6 @@ void Core_ReduceTest::run( int )
#define CHECK_C
Size sz(200, 500);
class Core_PCATest : public cvtest::BaseTest
{
public:
@ -293,6 +291,8 @@ public:
protected:
void run(int)
{
const Size sz(200, 500);
double diffPrjEps, diffBackPrjEps,
prjEps, backPrjEps,
evalEps, evecEps;

View File

@ -54,17 +54,17 @@ bool Core_RandTest::check_pdf(const Mat& hist, double scale,
}
else
{
double sum = 0, r = (hsz-1.)/2;
double sum2 = 0, r = (hsz-1.)/2;
double alpha = 2*sqrt(2.)/r, beta = -alpha*r;
for( i = 0; i < hsz; i++ )
{
double x = i*alpha + beta;
H0[i] = (float)exp(-x*x);
sum += H0[i];
sum2 += H0[i];
}
sum = 1./sum;
sum2 = 1./sum2;
for( i = 0; i < hsz; i++ )
H0[i] = (float)(H0[i]*sum);
H0[i] = (float)(H0[i]*sum2);
}
double chi2 = 0;
@ -253,7 +253,7 @@ void Core_RandTest::run( int )
if( do_sphere_test )
{
int SDIM = cvtest::randInt(rng) % (MAX_SDIM-1) + 2;
int N0 = (SZ*cn/SDIM), N = 0;
int N0 = (SZ*cn/SDIM), n = 0;
double r2 = 0;
const uchar* data = arr[0].data;
double scale[4], delta[4];
@ -276,13 +276,13 @@ void Core_RandTest::run( int )
r2 += val*val;
if( k == SDIM-1 )
{
N += r2 <= 1;
n += r2 <= 1;
r2 = 0;
k = -1;
}
}
double V = ((double)N/N0)*(1 << SDIM);
double V = ((double)n/N0)*(1 << SDIM);
// the theoretically computed volume
int sdim = SDIM % 2;

View File

@ -110,10 +110,10 @@ Mat BOWKMeansTrainer::cluster() const
BOWKMeansTrainer::~BOWKMeansTrainer()
{}
Mat BOWKMeansTrainer::cluster( const Mat& descriptors ) const
Mat BOWKMeansTrainer::cluster( const Mat& _descriptors ) const
{
Mat labels, vocabulary;
kmeans( descriptors, clusterCount, labels, termcrit, attempts, flags, vocabulary );
kmeans( _descriptors, clusterCount, labels, termcrit, attempts, flags, vocabulary );
return vocabulary;
}

View File

@ -127,8 +127,8 @@ int BriefDescriptorExtractor::descriptorType() const
void BriefDescriptorExtractor::read( const FileNode& fn)
{
int descriptorSize = fn["descriptorSize"];
switch (descriptorSize)
int dSize = fn["descriptorSize"];
switch (dSize)
{
case 16:
test_fn_ = pixelTests16;
@ -142,7 +142,7 @@ void BriefDescriptorExtractor::read( const FileNode& fn)
default:
CV_Error(CV_StsBadArg, "descriptorSize must be 16, 32, or 64");
}
bytes_ = descriptorSize;
bytes_ = dSize;
}
void BriefDescriptorExtractor::write( FileStorage& fs) const

View File

@ -223,8 +223,8 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector<
vector<KeyPoint> outKeypoints;
outKeypoints.reserve( keypoints.size() );
int descriptorSize = descriptorExtractor->descriptorSize();
Mat mergedDescriptors( maxKeypointsCount, 3*descriptorSize, descriptorExtractor->descriptorType() );
int dSize = descriptorExtractor->descriptorSize();
Mat mergedDescriptors( maxKeypointsCount, 3*dSize, descriptorExtractor->descriptorType() );
int mergedCount = 0;
// cp - current channel position
size_t cp[] = {0, 0, 0};
@ -250,7 +250,7 @@ void OpponentColorDescriptorExtractor::computeImpl( const Mat& bgrImage, vector<
// merge descriptors
for( int ci = 0; ci < N; ci++ )
{
Mat dst = mergedDescriptors(Range(mergedCount, mergedCount+1), Range(ci*descriptorSize, (ci+1)*descriptorSize));
Mat dst = mergedDescriptors(Range(mergedCount, mergedCount+1), Range(ci*dSize, (ci+1)*dSize));
channelDescriptors[ci].row( idxs[ci][cp[ci]] ).copyTo( dst );
cp[ci]++;
}

View File

@ -156,11 +156,11 @@ static void _prepareImgAndDrawKeypoints( const Mat& img1, const vector<KeyPoint>
// draw keypoints
if( !(flags & DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS) )
{
Mat outImg1 = outImg( Rect(0, 0, img1.cols, img1.rows) );
drawKeypoints( outImg1, keypoints1, outImg1, singlePointColor, flags + DrawMatchesFlags::DRAW_OVER_OUTIMG );
Mat _outImg1 = outImg( Rect(0, 0, img1.cols, img1.rows) );
drawKeypoints( _outImg1, keypoints1, _outImg1, singlePointColor, flags + DrawMatchesFlags::DRAW_OVER_OUTIMG );
Mat outImg2 = outImg( Rect(img1.cols, 0, img2.cols, img2.rows) );
drawKeypoints( outImg2, keypoints2, outImg2, singlePointColor, flags + DrawMatchesFlags::DRAW_OVER_OUTIMG );
Mat _outImg2 = outImg( Rect(img1.cols, 0, img2.cols, img2.rows) );
drawKeypoints( _outImg2, keypoints2, _outImg2, singlePointColor, flags + DrawMatchesFlags::DRAW_OVER_OUTIMG );
}
}
@ -179,8 +179,8 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 ,
dpt2 = Point2f( std::min(pt2.x+outImg1.cols, float(outImg.cols-1)), pt2.y );
line( outImg,
Point(cvRound(pt1.x*draw_multiplier), cvRound(pt1.y*draw_multiplier)),
Point(cvRound(dpt2.x*draw_multiplier), cvRound(dpt2.y*draw_multiplier)),
Point(cvRound(pt1.x*draw_multiplier), cvRound(pt1.y*draw_multiplier)),
Point(cvRound(dpt2.x*draw_multiplier), cvRound(dpt2.y*draw_multiplier)),
color, 1, CV_AA, draw_shift_bits );
}

View File

@ -109,11 +109,14 @@ class CV_EXPORTS HarrisDetector : public GFTTDetector
{
public:
HarrisDetector( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1,
int blockSize=3, bool useHarrisDetector=true, double k=0.04 )
: GFTTDetector( maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, k ) {}
int blockSize=3, bool useHarrisDetector=true, double k=0.04 );
AlgorithmInfo* info() const;
};
inline HarrisDetector::HarrisDetector( int _maxCorners, double _qualityLevel, double _minDistance,
int _blockSize, bool _useHarrisDetector, double _k )
: GFTTDetector( _maxCorners, _qualityLevel, _minDistance, _blockSize, _useHarrisDetector, _k ) {}
CV_INIT_ALGORITHM(HarrisDetector, "Feature2D.HARRIS",
obj.info()->addParam(obj, "nfeatures", obj.nfeatures);
obj.info()->addParam(obj, "qualityLevel", obj.qualityLevel);

View File

@ -539,7 +539,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
for(int i = 0; i < (int)ip.size(); ++i)
{
CV_Assert(ip[i].type() == FileNode::MAP);
std::string name = (std::string)ip[i]["name"];
std::string _name = (std::string)ip[i]["name"];
int type = (int)ip[i]["type"];
switch(type)
@ -549,19 +549,19 @@ void FlannBasedMatcher::read( const FileNode& fn)
case CV_16U:
case CV_16S:
case CV_32S:
indexParams->setInt(name, (int) ip[i]["value"]);
indexParams->setInt(_name, (int) ip[i]["value"]);
break;
case CV_32F:
indexParams->setFloat(name, (float) ip[i]["value"]);
indexParams->setFloat(_name, (float) ip[i]["value"]);
break;
case CV_64F:
indexParams->setDouble(name, (double) ip[i]["value"]);
indexParams->setDouble(_name, (double) ip[i]["value"]);
break;
case CV_USRTYPE1:
indexParams->setString(name, (std::string) ip[i]["value"]);
indexParams->setString(_name, (std::string) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
indexParams->setBool(name, (int) ip[i]["value"] != 0);
indexParams->setBool(_name, (int) ip[i]["value"] != 0);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
indexParams->setAlgorithm((int) ip[i]["value"]);
@ -578,7 +578,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
for(int i = 0; i < (int)sp.size(); ++i)
{
CV_Assert(sp[i].type() == FileNode::MAP);
std::string name = (std::string)sp[i]["name"];
std::string _name = (std::string)sp[i]["name"];
int type = (int)sp[i]["type"];
switch(type)
@ -588,19 +588,19 @@ void FlannBasedMatcher::read( const FileNode& fn)
case CV_16U:
case CV_16S:
case CV_32S:
searchParams->setInt(name, (int) sp[i]["value"]);
searchParams->setInt(_name, (int) sp[i]["value"]);
break;
case CV_32F:
searchParams->setFloat(name, (float) ip[i]["value"]);
searchParams->setFloat(_name, (float) ip[i]["value"]);
break;
case CV_64F:
searchParams->setDouble(name, (double) ip[i]["value"]);
searchParams->setDouble(_name, (double) ip[i]["value"]);
break;
case CV_USRTYPE1:
searchParams->setString(name, (std::string) ip[i]["value"]);
searchParams->setString(_name, (std::string) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
searchParams->setBool(name, (int) ip[i]["value"] != 0);
searchParams->setBool(_name, (int) ip[i]["value"] != 0);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
searchParams->setAlgorithm((int) ip[i]["value"]);

View File

@ -539,8 +539,8 @@ static void extractMSER_8UC1_Pass( int* ioptr,
}
*imgptr += 0x10000;
}
int i = (int)(imgptr-ioptr);
ptsptr->pt = cvPoint( i&stepmask, i>>stepgap );
int imsk = (int)(imgptr-ioptr);
ptsptr->pt = cvPoint( imsk&stepmask, imsk>>stepgap );
// get the current location
accumulateMSERComp( comptr, ptsptr );
ptsptr++;

View File

@ -555,9 +555,9 @@ static inline float getScale(int level, int firstLevel, double scaleFactor)
* @param detector_params parameters to use
*/
ORB::ORB(int _nfeatures, float _scaleFactor, int _nlevels, int _edgeThreshold,
int _firstLevel, int WTA_K, int _scoreType, int _patchSize) :
int _firstLevel, int _WTA_K, int _scoreType, int _patchSize) :
nfeatures(_nfeatures), scaleFactor(_scaleFactor), nlevels(_nlevels),
edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), WTA_K(WTA_K),
edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), WTA_K(_WTA_K),
scoreType(_scoreType), patchSize(_patchSize)
{}
@ -653,8 +653,8 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
for (int level = 0; level < nlevels; ++level)
{
int nfeatures = nfeaturesPerLevel[level];
allKeypoints[level].reserve(nfeatures*2);
int featuresNum = nfeaturesPerLevel[level];
allKeypoints[level].reserve(featuresNum*2);
vector<KeyPoint> & keypoints = allKeypoints[level];
@ -668,14 +668,14 @@ static void computeKeyPoints(const vector<Mat>& imagePyramid,
if( scoreType == ORB::HARRIS_SCORE )
{
// Keep more points than necessary as FAST does not give amazing corners
KeyPointsFilter::retainBest(keypoints, 2 * nfeatures);
KeyPointsFilter::retainBest(keypoints, 2 * featuresNum);
// Compute the Harris cornerness (better scoring than FAST)
HarrisResponses(imagePyramid[level], keypoints, 7, HARRIS_K);
}
//cull to the final desired level, using the new Harris scores or the original FAST scores.
KeyPointsFilter::retainBest(keypoints, nfeatures);
KeyPointsFilter::retainBest(keypoints, featuresNum);
float sf = getScale(level, firstLevel, scaleFactor);
@ -738,7 +738,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
if( image.type() != CV_8UC1 )
cvtColor(_image, image, CV_BGR2GRAY);
int nlevels = this->nlevels;
int levelsNum = this->nlevels;
if( !do_keypoints )
{
@ -751,15 +751,15 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
//
// In short, ultimately the descriptor should
// ignore octave parameter and deal only with the keypoint size.
nlevels = 0;
levelsNum = 0;
for( size_t i = 0; i < _keypoints.size(); i++ )
nlevels = std::max(nlevels, std::max(_keypoints[i].octave, 0));
nlevels++;
levelsNum = std::max(levelsNum, std::max(_keypoints[i].octave, 0));
levelsNum++;
}
// Pre-compute the scale pyramids
vector<Mat> imagePyramid(nlevels), maskPyramid(nlevels);
for (int level = 0; level < nlevels; ++level)
vector<Mat> imagePyramid(levelsNum), maskPyramid(levelsNum);
for (int level = 0; level < levelsNum; ++level)
{
float scale = 1/getScale(level, firstLevel, scaleFactor);
Size sz(cvRound(image.cols*scale), cvRound(image.rows*scale));
@ -839,13 +839,13 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
KeyPointsFilter::runByImageBorder(_keypoints, image.size(), edgeThreshold);
// Cluster the input keypoints depending on the level they were computed at
allKeypoints.resize(nlevels);
allKeypoints.resize(levelsNum);
for (vector<KeyPoint>::iterator keypoint = _keypoints.begin(),
keypointEnd = _keypoints.end(); keypoint != keypointEnd; ++keypoint)
allKeypoints[keypoint->octave].push_back(*keypoint);
// Make sure we rescale the coordinates
for (int level = 0; level < nlevels; ++level)
for (int level = 0; level < levelsNum; ++level)
{
if (level == firstLevel)
continue;
@ -864,7 +864,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
if( do_descriptors )
{
int nkeypoints = 0;
for (int level = 0; level < nlevels; ++level)
for (int level = 0; level < levelsNum; ++level)
nkeypoints += (int)allKeypoints[level].size();
if( nkeypoints == 0 )
_descriptors.release();
@ -897,7 +897,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, vector<KeyPoint>& _ke
_keypoints.clear();
int offset = 0;
for (int level = 0; level < nlevels; ++level)
for (int level = 0; level < levelsNum; ++level)
{
// Get the features and compute their orientation
vector<KeyPoint>& keypoints = allKeypoints[level];

View File

@ -121,7 +121,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
StarFeature f[MAX_PATTERN];
Mat sum, tilted, flatTilted;
int y, i=0, rows = img.rows, cols = img.cols;
int y, rows = img.rows, cols = img.cols;
int border, npatterns=0, maxIdx=0;
CV_Assert( img.type() == CV_8UC1 );
@ -129,21 +129,20 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
responses.create( img.size(), CV_32F );
sizes.create( img.size(), CV_16S );
while( pairs[i][0] >= 0 && !
( sizes0[pairs[i][0]] >= maxSize
|| sizes0[pairs[i+1][0]] + sizes0[pairs[i+1][0]]/2 >= std::min(rows, cols) ) )
while( pairs[npatterns][0] >= 0 && !
( sizes0[pairs[npatterns][0]] >= maxSize
|| sizes0[pairs[npatterns+1][0]] + sizes0[pairs[npatterns+1][0]]/2 >= std::min(rows, cols) ) )
{
++i;
++npatterns;
}
npatterns = i;
npatterns += (pairs[npatterns-1][0] >= 0);
maxIdx = pairs[npatterns-1][0];
computeIntegralImages( img, sum, tilted, flatTilted );
int step = (int)(sum.step/sum.elemSize());
for( i = 0; i <= maxIdx; i++ )
for(int i = 0; i <= maxIdx; i++ )
{
int ur_size = sizes0[i], t_size = sizes0[i] + sizes0[i]/2;
int ur_area = (2*ur_size + 1)*(2*ur_size + 1);
@ -169,7 +168,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
sizes1[maxIdx] = -sizes1[maxIdx];
border = sizes0[maxIdx] + sizes0[maxIdx]/2;
for( i = 0; i < npatterns; i++ )
for(int i = 0; i < npatterns; i++ )
{
int innerArea = f[pairs[i][1]].area;
int outerArea = f[pairs[i][0]].area - innerArea;
@ -180,13 +179,13 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
#if CV_SSE2
if( useSIMD )
{
for( i = 0; i < npatterns; i++ )
for(int i = 0; i < npatterns; i++ )
{
_mm_store_ps((float*)&invSizes4[i][0], _mm_set1_ps(invSizes[i][0]));
_mm_store_ps((float*)&invSizes4[i][1], _mm_set1_ps(invSizes[i][1]));
}
for( i = 0; i <= maxIdx; i++ )
for(int i = 0; i <= maxIdx; i++ )
_mm_store_ps((float*)&sizes1_4[i], _mm_set1_ps((float)sizes1[i]));
}
#endif
@ -206,7 +205,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
for( y = border; y < rows - border; y++ )
{
int x = border, i;
int x = border;
float* r_ptr = responses.ptr<float>(y);
short* s_ptr = sizes.ptr<short>(y);
@ -226,7 +225,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
__m128 bestResponse = _mm_setzero_ps();
__m128 bestSize = _mm_setzero_ps();
for( i = 0; i <= maxIdx; i++ )
for(int i = 0; i <= maxIdx; i++ )
{
const int** p = (const int**)&f[i].p[0];
__m128i r0 = _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(p[0]+ofs)),
@ -241,7 +240,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
_mm_store_ps((float*)&vals[i], _mm_cvtepi32_ps(r0));
}
for( i = 0; i < npatterns; i++ )
for(int i = 0; i < npatterns; i++ )
{
__m128 inner_sum = vals[pairs[i][1]];
__m128 outer_sum = _mm_sub_ps(vals[pairs[i][0]], inner_sum);
@ -268,13 +267,13 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
float bestResponse = 0;
int bestSize = 0;
for( i = 0; i <= maxIdx; i++ )
for(int i = 0; i <= maxIdx; i++ )
{
const int** p = (const int**)&f[i].p[0];
vals[i] = p[0][ofs] - p[1][ofs] - p[2][ofs] + p[3][ofs] +
p[4][ofs] - p[5][ofs] - p[6][ofs] + p[7][ofs];
}
for( i = 0; i < npatterns; i++ )
for(int i = 0; i < npatterns; i++ )
{
int inner_sum = vals[pairs[i][1]];
int outer_sum = vals[pairs[i][0]] - inner_sum;

View File

@ -92,9 +92,9 @@ public:
/**
Default constructor. Initializes a new pool.
*/
PooledAllocator(int blocksize = BLOCKSIZE)
PooledAllocator(int blockSize = BLOCKSIZE)
{
this->blocksize = blocksize;
blocksize = blockSize;
remaining = 0;
base = NULL;
@ -122,7 +122,7 @@ public:
*/
void* allocateMemory(int size)
{
int blocksize;
int blockSize;
/* Round size up to a multiple of wordsize. The following expression
only works for WORDSIZE that is a power of 2, by masking last bits of
@ -138,11 +138,11 @@ public:
wastedMemory += remaining;
/* Allocate new storage. */
blocksize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ?
blockSize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ?
size + sizeof(void*) + (WORDSIZE-1) : BLOCKSIZE;
// use the standard C malloc to allocate memory
void* m = ::malloc(blocksize);
void* m = ::malloc(blockSize);
if (!m) {
fprintf(stderr,"Failed to allocate memory.\n");
return NULL;
@ -155,7 +155,7 @@ public:
int shift = 0;
//int shift = (WORDSIZE - ( (((size_t)m) + sizeof(void*)) & (WORDSIZE-1))) & (WORDSIZE-1);
remaining = blocksize - sizeof(void*) - shift;
remaining = blockSize - sizeof(void*) - shift;
loc = ((char*)m + sizeof(void*) + shift);
}
void* rloc = loc;

View File

@ -66,9 +66,9 @@ public:
/** @param only constructor we use in our code
* @param the size of the bitset (in bits)
*/
DynamicBitset(size_t size)
DynamicBitset(size_t sz)
{
resize(size);
resize(sz);
reset();
}
@ -116,10 +116,10 @@ public:
/** @param resize the bitset so that it contains at least size bits
* @param size
*/
void resize(size_t size)
void resize(size_t sz)
{
size_ = size;
bitset_.resize(size / cell_bit_size_ + 1);
size_ = sz;
bitset_.resize(sz / cell_bit_size_ + 1);
}
/** @param set a bit to true

View File

@ -67,12 +67,12 @@ public:
* Constructor.
*
* Params:
* size = heap size
* sz = heap size
*/
Heap(int size)
Heap(int sz)
{
length = size;
length = sz;
heap.reserve(length);
count = 0;
}

View File

@ -106,7 +106,7 @@ private:
* indices_length = length of indices vector
*
*/
void chooseCentersRandom(int k, int* indices, int indices_length, int* centers, int& centers_length)
void chooseCentersRandom(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
{
UniqueRandom r(indices_length);
@ -122,7 +122,7 @@ private:
return;
}
centers[index] = indices[rnd];
centers[index] = dsindices[rnd];
for (int j=0; j<index; ++j) {
DistanceType sq = distance(dataset[centers[index]], dataset[centers[j]], dataset.cols);
@ -147,14 +147,14 @@ private:
* indices = indices in the dataset
* Returns:
*/
void chooseCentersGonzales(int k, int* indices, int indices_length, int* centers, int& centers_length)
void chooseCentersGonzales(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
{
int n = indices_length;
int rnd = rand_int(n);
assert(rnd >=0 && rnd < n);
centers[0] = indices[rnd];
centers[0] = dsindices[rnd];
int index;
for (index=1; index<k; ++index) {
@ -162,9 +162,9 @@ private:
int best_index = -1;
DistanceType best_val = 0;
for (int j=0; j<n; ++j) {
DistanceType dist = distance(dataset[centers[0]],dataset[indices[j]],dataset.cols);
DistanceType dist = distance(dataset[centers[0]],dataset[dsindices[j]],dataset.cols);
for (int i=1; i<index; ++i) {
DistanceType tmp_dist = distance(dataset[centers[i]],dataset[indices[j]],dataset.cols);
DistanceType tmp_dist = distance(dataset[centers[i]],dataset[dsindices[j]],dataset.cols);
if (tmp_dist<dist) {
dist = tmp_dist;
}
@ -175,7 +175,7 @@ private:
}
}
if (best_index!=-1) {
centers[index] = indices[best_index];
centers[index] = dsindices[best_index];
}
else {
break;
@ -198,7 +198,7 @@ private:
* indices = indices in the dataset
* Returns:
*/
void chooseCentersKMeanspp(int k, int* indices, int indices_length, int* centers, int& centers_length)
void chooseCentersKMeanspp(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
{
int n = indices_length;
@ -208,10 +208,10 @@ private:
// Choose one random center and set the closestDistSq values
int index = rand_int(n);
assert(index >=0 && index < n);
centers[0] = indices[index];
centers[0] = dsindices[index];
for (int i = 0; i < n; i++) {
closestDistSq[i] = distance(dataset[indices[i]], dataset[indices[index]], dataset.cols);
closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols);
currentPot += closestDistSq[i];
}
@ -237,7 +237,7 @@ private:
// Compute the new potential
double newPot = 0;
for (int i = 0; i < n; i++) newPot += std::min( distance(dataset[indices[i]], dataset[indices[index]], dataset.cols), closestDistSq[i] );
for (int i = 0; i < n; i++) newPot += std::min( distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols), closestDistSq[i] );
// Store the best result
if ((bestNewPot < 0)||(newPot < bestNewPot)) {
@ -247,9 +247,9 @@ private:
}
// Add the appropriate center
centers[centerCount] = indices[bestNewIndex];
centers[centerCount] = dsindices[bestNewIndex];
currentPot = bestNewPot;
for (int i = 0; i < n; i++) closestDistSq[i] = std::min( distance(dataset[indices[i]], dataset[indices[bestNewIndex]], dataset.cols), closestDistSq[i] );
for (int i = 0; i < n; i++) closestDistSq[i] = std::min( distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols), closestDistSq[i] );
}
centers_length = centerCount;
@ -518,11 +518,11 @@ private:
void computeLabels(int* indices, int indices_length, int* centers, int centers_length, int* labels, DistanceType& cost)
void computeLabels(int* dsindices, int indices_length, int* centers, int centers_length, int* labels, DistanceType& cost)
{
cost = 0;
for (int i=0; i<indices_length; ++i) {
ElementType* point = dataset[indices[i]];
ElementType* point = dataset[dsindices[i]];
DistanceType dist = distance(point, dataset[centers[0]], veclen_);
labels[i] = 0;
for (int j=1; j<centers_length; ++j) {
@ -547,13 +547,13 @@ private:
*
* TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point)
*/
void computeClustering(NodePtr node, int* indices, int indices_length, int branching, int level)
void computeClustering(NodePtr node, int* dsindices, int indices_length, int branching, int level)
{
node->size = indices_length;
node->level = level;
if (indices_length < leaf_size_) { // leaf node
node->indices = indices;
node->indices = dsindices;
std::sort(node->indices,node->indices+indices_length);
node->childs = NULL;
return;
@ -563,10 +563,10 @@ private:
std::vector<int> labels(indices_length);
int centers_length;
(this->*chooseCenters)(branching, indices, indices_length, &centers[0], centers_length);
(this->*chooseCenters)(branching, dsindices, indices_length, &centers[0], centers_length);
if (centers_length<branching) {
node->indices = indices;
node->indices = dsindices;
std::sort(node->indices,node->indices+indices_length);
node->childs = NULL;
return;
@ -575,7 +575,7 @@ private:
// assign points to clusters
DistanceType cost;
computeLabels(indices, indices_length, &centers[0], centers_length, &labels[0], cost);
computeLabels(dsindices, indices_length, &centers[0], centers_length, &labels[0], cost);
node->childs = pool.allocate<NodePtr>(branching);
int start = 0;
@ -583,7 +583,7 @@ private:
for (int i=0; i<branching; ++i) {
for (int j=0; j<indices_length; ++j) {
if (labels[j]==i) {
std::swap(indices[j],indices[end]);
std::swap(dsindices[j],dsindices[end]);
std::swap(labels[j],labels[end]);
end++;
}
@ -592,7 +592,7 @@ private:
node->childs[i] = pool.allocate<Node>();
node->childs[i]->pivot = centers[i];
node->childs[i]->indices = NULL;
computeClustering(node->childs[i],indices+start, end-start, branching, level+1);
computeClustering(node->childs[i],dsindices+start, end-start, branching, level+1);
start=end;
}
}

View File

@ -5,9 +5,7 @@ endif()
set(the_description "GPU-accelerated Computer Vision")
ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_nonfree opencv_legacy)
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../highgui/src")
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda" "${CMAKE_CURRENT_SOURCE_DIR}/../highgui/src")
file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
file(GLOB lib_int_hdrs "src/*.hpp" "src/*.h")
@ -30,17 +28,14 @@ if (HAVE_CUDA)
set(ncv_files ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda})
source_group("Src\\NVidia" FILES ${ncv_files})
include_directories(AFTER SYSTEM ${CUDA_INCLUDE_DIRS})
ocv_include_directories("src/nvidia" "src/nvidia/core" "src/nvidia/NPP_staging")
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
ocv_include_directories("src/nvidia" "src/nvidia/core" "src/nvidia/NPP_staging" ${CUDA_INCLUDE_DIRS})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef /wd4211 /wd4201 /wd4100 /wd4505 /wd4408)
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
if(MSVC)
if(NOT ENABLE_NOISY_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408")
foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "/W4" "/W3" ${var} "${${var}}")
endforeach()
@ -52,10 +47,8 @@ if (HAVE_CUDA)
ocv_cuda_compile(cuda_objs ${lib_cuda} ${ncv_cuda})
#CUDA_BUILD_CLEAN_TARGET()
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
if(NOT APPLE)
unset(CUDA_nvcuvid_LIBRARY CACHE)
find_cuda_helper_libs(nvcuvid)
@ -106,11 +99,11 @@ ocv_add_precompiled_headers(${the_module})
################################################################################################################
file(GLOB test_srcs "test/*.cpp")
file(GLOB test_hdrs "test/*.hpp" "test/*.h")
set(nvidia "")
if(HAVE_CUDA)
file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.hpp" "test/nvidia/*.h")
set(nvidia FILES "Src\\\\\\\\NVidia" ${nvidia}) # 8 ugly backslashes :'(
else()
set(nvidia "")
endif()
ocv_add_accuracy_tests(FILES "Include" ${test_hdrs}

View File

@ -134,7 +134,7 @@ endif()
if(HAVE_OPENNI)
list(APPEND highgui_srcs src/cap_openni.cpp)
include_directories(AFTER SYSTEM ${OPENNI_INCLUDE_DIR})
ocv_include_directories(${OPENNI_INCLUDE_DIR})
list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
endif(HAVE_OPENNI)

View File

@ -357,13 +357,13 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
if(manualpipeline) {
GstIterator *it = gst_bin_iterate_sinks(GST_BIN(uridecodebin));
if(gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) {
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
pipeline = uridecodebin;
pipeline = uridecodebin;
} else {
pipeline = gst_pipeline_new (NULL);
pipeline = gst_pipeline_new (NULL);
color = gst_element_factory_make("ffmpegcolorspace", NULL);
sink = gst_element_factory_make("appsink", NULL);
@ -381,16 +381,12 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
gst_app_sink_set_max_buffers (GST_APP_SINK(sink), 1);
gst_app_sink_set_drop (GST_APP_SINK(sink), stream);
{
GstCaps* caps;
caps = gst_caps_new_simple("video/x-raw-rgb",
"red_mask", G_TYPE_INT, 0x0000FF,
"green_mask", G_TYPE_INT, 0x00FF00,
"blue_mask", G_TYPE_INT, 0xFF0000,
NULL);
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
gst_app_sink_set_caps(GST_APP_SINK(sink), gst_caps_new_simple("video/x-raw-rgb",
"red_mask", G_TYPE_INT, 0x0000FF,
"green_mask", G_TYPE_INT, 0x00FF00,
"blue_mask", G_TYPE_INT, 0xFF0000,
NULL));
gst_caps_unref(caps);
}
if(gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY) ==
GST_STATE_CHANGE_FAILURE) {

View File

@ -779,9 +779,9 @@ static int _capture_V4L2 (CvCaptureCAM_V4L *capture, char *deviceName)
return -1;
} else {
buffer_number--;
fprintf (stderr, "Insufficient buffer memory on %s -- decreaseing buffers\n", deviceName);
fprintf (stderr, "Insufficient buffer memory on %s -- decreaseing buffers\n", deviceName);
goto try_again;
goto try_again;
}
}
@ -824,7 +824,7 @@ static int _capture_V4L2 (CvCaptureCAM_V4L *capture, char *deviceName)
if (capture->buffers[MAX_V4L_BUFFERS].start) {
free(capture->buffers[MAX_V4L_BUFFERS].start);
capture->buffers[MAX_V4L_BUFFERS].start = NULL;
}
}
capture->buffers[MAX_V4L_BUFFERS].start = malloc(buf.length);
capture->buffers[MAX_V4L_BUFFERS].length = buf.length;
@ -1080,11 +1080,11 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
#ifdef USE_TEMP_BUFFER
memcpy(capture->buffers[MAX_V4L_BUFFERS].start,
capture->buffers[buf.index].start,
capture->buffers[MAX_V4L_BUFFERS].length );
capture->buffers[buf.index].start,
capture->buffers[MAX_V4L_BUFFERS].length );
capture->bufferIndex = MAX_V4L_BUFFERS;
//printf("got data in buff %d, len=%d, flags=0x%X, seq=%d, used=%d)\n",
// buf.index, buf.length, buf.flags, buf.sequence, buf.bytesused);
// buf.index, buf.length, buf.flags, buf.sequence, buf.bytesused);
#else
capture->bufferIndex = buf.index;
#endif
@ -1211,9 +1211,9 @@ static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
capture->mmaps[capture->bufferIndex].format = capture->imageProperties.palette;
if (v4l1_ioctl (capture->deviceHandle, VIDIOCMCAPTURE,
&capture->mmaps[capture->bufferIndex]) == -1) {
/* capture is on the way, so just exit */
return 1;
&capture->mmaps[capture->bufferIndex]) == -1) {
/* capture is on the way, so just exit */
return 1;
}
++capture->bufferIndex;
@ -1273,11 +1273,11 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
if (capture->is_v4l2_device == 1)
{
if(capture->buffers[capture->bufferIndex].start){
memcpy((char *)capture->frame.imageData,
(char *)capture->buffers[capture->bufferIndex].start,
capture->frame.imageSize);
}
if(capture->buffers[capture->bufferIndex].start){
memcpy((char *)capture->frame.imageData,
(char *)capture->buffers[capture->bufferIndex].start,
capture->frame.imageSize);
}
} else
#endif /* HAVE_CAMV4L2 */
@ -1688,8 +1688,8 @@ static void icvCloseCAM_V4L( CvCaptureCAM_V4L* capture ){
if (xioctl(capture->deviceHandle, VIDIOC_STREAMOFF, &capture->type) < 0) {
perror ("Unable to stop the stream.");
}
for (unsigned int n_buffers = 0; n_buffers < capture->req.count; ++n_buffers) {
if (-1 == v4l2_munmap (capture->buffers[n_buffers].start, capture->buffers[n_buffers].length)) {
for (unsigned int n_buffers2 = 0; n_buffers2 < capture->req.count; ++n_buffers2) {
if (-1 == v4l2_munmap (capture->buffers[n_buffers2].start, capture->buffers[n_buffers2].length)) {
perror ("munmap");
}
}

View File

@ -157,16 +157,16 @@ bool PngDecoder::readHeader()
if( !m_buf.empty() || m_f )
{
png_uint_32 width, height;
png_uint_32 wdth, hght;
int bit_depth, color_type;
png_read_info( png_ptr, info_ptr );
png_get_IHDR( png_ptr, info_ptr, &width, &height,
png_get_IHDR( png_ptr, info_ptr, &wdth, &hght,
&bit_depth, &color_type, 0, 0, 0 );
m_width = (int)width;
m_height = (int)height;
m_width = (int)wdth;
m_height = (int)hght;
m_color_type = color_type;
m_bit_depth = bit_depth;

View File

@ -115,19 +115,19 @@ bool TiffDecoder::readHeader()
if( tif )
{
int width = 0, height = 0, photometric = 0;
int wdth = 0, hght = 0, photometric = 0;
m_tif = tif;
if( TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &width ) &&
TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &height ) &&
if( TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &wdth ) &&
TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &hght ) &&
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric ))
{
int bpp=8, ncn = photometric > 1 ? 3 : 1;
TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bpp );
TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &ncn );
m_width = width;
m_height = height;
m_width = wdth;
m_height = hght;
if( bpp > 8 &&
((photometric != 2 && photometric != 1) ||
(ncn != 1 && ncn != 3 && ncn != 4)))

View File

@ -60,9 +60,9 @@ protected:
void CV_DrawingTest::run( int )
{
Mat testImg, valImg;
const string name = "drawing/image.jpg";
const string fname = "drawing/image.jpg";
string path = ts->get_data_path(), filename;
filename = path + name;
filename = path + fname;
draw( testImg );

View File

@ -403,7 +403,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
if (!writer.isOpened())
{
// call it repeatedly for easier debugging
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
VideoWriter writer2(video_file, fourcc, 25, frame_size, true);
ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
ts->printf(ts->LOG, "Cannot create VideoWriter object with codec %s.\n", fourcc_str.c_str());
ts->set_failed_test_info(ts->FAIL_MISMATCH);

View File

@ -225,7 +225,7 @@ struct RGB5x52RGB
typedef uchar channel_type;
RGB5x52RGB(int _dstcn, int _blueIdx, int _greenBits)
: dstcn(_dstcn), blueIdx(_blueIdx), greenBits(_greenBits) {}
: dstcn(_dstcn), blueIdx(_blueIdx), greenBits(_greenBits) {}
void operator()(const uchar* src, uchar* dst, int n) const
{
@ -261,7 +261,7 @@ struct RGB2RGB5x5
typedef uchar channel_type;
RGB2RGB5x5(int _srccn, int _blueIdx, int _greenBits)
: srccn(_srccn), blueIdx(_blueIdx), greenBits(_greenBits) {}
: srccn(_srccn), blueIdx(_blueIdx), greenBits(_greenBits) {}
void operator()(const uchar* src, uchar* dst, int n) const
{
@ -430,11 +430,11 @@ template<> struct RGB2Gray<uchar>
void operator()(const uchar* src, uchar* dst, int n) const
{
int scn = srccn;
const int* _tab = tab;
const int* _tab = tab;
for(int i = 0; i < n; i++, src += scn)
dst[i] = (uchar)((_tab[src[0]] + _tab[src[1]+256] + _tab[src[2]+512]) >> yuv_shift);
}
int srccn, blueIdx;
int srccn;
int tab[256*3];
};
@ -469,17 +469,17 @@ template<typename _Tp> struct RGB2YCrCb_f
typedef _Tp channel_type;
RGB2YCrCb_f(int _srccn, int _blueIdx, const float* _coeffs) : srccn(_srccn), blueIdx(_blueIdx)
{
static const float coeffs0[] = {0.299f, 0.587f, 0.114f, 0.713f, 0.564f};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 5*sizeof(coeffs[0]));
if(blueIdx==0) std::swap(coeffs[0], coeffs[2]);
}
{
static const float coeffs0[] = {0.299f, 0.587f, 0.114f, 0.713f, 0.564f};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 5*sizeof(coeffs[0]));
if(blueIdx==0) std::swap(coeffs[0], coeffs[2]);
}
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int scn = srccn, bidx = blueIdx;
const _Tp delta = ColorChannel<_Tp>::half();
float C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2], C3 = coeffs[3], C4 = coeffs[4];
float C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2], C3 = coeffs[3], C4 = coeffs[4];
n *= 3;
for(int i = 0; i < n; i += 3, src += scn)
{
@ -490,7 +490,7 @@ template<typename _Tp> struct RGB2YCrCb_f
}
}
int srccn, blueIdx;
float coeffs[5];
float coeffs[5];
};
@ -499,16 +499,16 @@ template<typename _Tp> struct RGB2YCrCb_i
typedef _Tp channel_type;
RGB2YCrCb_i(int _srccn, int _blueIdx, const int* _coeffs)
: srccn(_srccn), blueIdx(_blueIdx)
{
static const int coeffs0[] = {R2Y, G2Y, B2Y, 11682, 9241};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 5*sizeof(coeffs[0]));
if(blueIdx==0) std::swap(coeffs[0], coeffs[2]);
}
: srccn(_srccn), blueIdx(_blueIdx)
{
static const int coeffs0[] = {R2Y, G2Y, B2Y, 11682, 9241};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 5*sizeof(coeffs[0]));
if(blueIdx==0) std::swap(coeffs[0], coeffs[2]);
}
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int scn = srccn, bidx = blueIdx;
int C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2], C3 = coeffs[3], C4 = coeffs[4];
int C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2], C3 = coeffs[3], C4 = coeffs[4];
int delta = ColorChannel<_Tp>::half()*(1 << yuv_shift);
n *= 3;
for(int i = 0; i < n; i += 3, src += scn)
@ -522,7 +522,7 @@ template<typename _Tp> struct RGB2YCrCb_i
}
}
int srccn, blueIdx;
int coeffs[5];
int coeffs[5];
};
@ -531,11 +531,11 @@ template<typename _Tp> struct YCrCb2RGB_f
typedef _Tp channel_type;
YCrCb2RGB_f(int _dstcn, int _blueIdx, const float* _coeffs)
: dstcn(_dstcn), blueIdx(_blueIdx)
{
static const float coeffs0[] = {1.403f, -0.714f, -0.344f, 1.773f};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 4*sizeof(coeffs[0]));
}
: dstcn(_dstcn), blueIdx(_blueIdx)
{
static const float coeffs0[] = {1.403f, -0.714f, -0.344f, 1.773f};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 4*sizeof(coeffs[0]));
}
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int dcn = dstcn, bidx = blueIdx;
@ -558,7 +558,7 @@ template<typename _Tp> struct YCrCb2RGB_f
}
}
int dstcn, blueIdx;
float coeffs[4];
float coeffs[4];
};
@ -570,7 +570,7 @@ template<typename _Tp> struct YCrCb2RGB_i
: dstcn(_dstcn), blueIdx(_blueIdx)
{
static const int coeffs0[] = {22987, -11698, -5636, 29049};
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 4*sizeof(coeffs[0]));
memcpy(coeffs, _coeffs ? _coeffs : coeffs0, 4*sizeof(coeffs[0]));
}
void operator()(const _Tp* src, _Tp* dst, int n) const
@ -641,9 +641,9 @@ template<typename _Tp> struct RGB2XYZ_f
n *= 3;
for(int i = 0; i < n; i += 3, src += scn)
{
_Tp X = saturate_cast<_Tp>(src[0]*C0 + src[1]*C1 + src[2]*C2);
_Tp Y = saturate_cast<_Tp>(src[0]*C3 + src[1]*C4 + src[2]*C5);
_Tp Z = saturate_cast<_Tp>(src[0]*C6 + src[1]*C7 + src[2]*C8);
_Tp X = saturate_cast<_Tp>(src[0]*C0 + src[1]*C1 + src[2]*C2);
_Tp Y = saturate_cast<_Tp>(src[0]*C3 + src[1]*C4 + src[2]*C5);
_Tp Z = saturate_cast<_Tp>(src[0]*C6 + src[1]*C7 + src[2]*C8);
dst[i] = X; dst[i+1] = Y; dst[i+2] = Z;
}
}
@ -713,19 +713,19 @@ template<typename _Tp> struct XYZ2RGB_f
void operator()(const _Tp* src, _Tp* dst, int n) const
{
int dcn = dstcn;
_Tp alpha = ColorChannel<_Tp>::max();
_Tp alpha = ColorChannel<_Tp>::max();
float C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2],
C3 = coeffs[3], C4 = coeffs[4], C5 = coeffs[5],
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
n *= 3;
for(int i = 0; i < n; i += 3, dst += dcn)
{
_Tp B = saturate_cast<_Tp>(src[i]*C0 + src[i+1]*C1 + src[i+2]*C2);
_Tp G = saturate_cast<_Tp>(src[i]*C3 + src[i+1]*C4 + src[i+2]*C5);
_Tp R = saturate_cast<_Tp>(src[i]*C6 + src[i+1]*C7 + src[i+2]*C8);
_Tp B = saturate_cast<_Tp>(src[i]*C0 + src[i+1]*C1 + src[i+2]*C2);
_Tp G = saturate_cast<_Tp>(src[i]*C3 + src[i+1]*C4 + src[i+2]*C5);
_Tp R = saturate_cast<_Tp>(src[i]*C6 + src[i+1]*C7 + src[i+2]*C8);
dst[0] = B; dst[1] = G; dst[2] = R;
if( dcn == 4 )
dst[3] = alpha;
if( dcn == 4 )
dst[3] = alpha;
}
}
int dstcn, blueIdx;
@ -772,7 +772,7 @@ template<typename _Tp> struct XYZ2RGB_i
dst[0] = saturate_cast<_Tp>(B); dst[1] = saturate_cast<_Tp>(G);
dst[2] = saturate_cast<_Tp>(R);
if( dcn == 4 )
dst[3] = alpha;
dst[3] = alpha;
}
}
int dstcn, blueIdx;
@ -1503,7 +1503,7 @@ struct RGB2Luv_f
const float* whitept, bool _srgb )
: srccn(_srccn), srgb(_srgb)
{
volatile int i;
volatile int i;
initLabTabs();
if(!_coeffs) _coeffs = sRGB2XYZ_D65;
@ -3354,7 +3354,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
code == CV_BGR2HSV_FULL || code == CV_RGB2HSV_FULL )
{
#ifdef HAVE_TEGRA_OPTIMIZATION
if(tegra::cvtRGB2HSV(src, dst, bidx, hrange))
if(tegra::cvtRGB2HSV(src, dst, bidx, hrange))
break;
#endif
if( depth == CV_8U )
@ -3510,8 +3510,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
// http://www.fourcc.org/yuv.php#NV12 -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
if (dcn <= 0) dcn = (code==CV_YUV420sp2BGRA || code==CV_YUV420sp2RGBA || code==CV_YUV2BGRA_NV12 || code==CV_YUV2RGBA_NV12) ? 4 : 3;
const int bidx = (code==CV_YUV2BGR_NV21 || code==CV_YUV2BGRA_NV21 || code==CV_YUV2BGR_NV12 || code==CV_YUV2BGRA_NV12) ? 0 : 2;
const int uidx = (code==CV_YUV2BGR_NV21 || code==CV_YUV2BGRA_NV21 || code==CV_YUV2RGB_NV21 || code==CV_YUV2RGBA_NV21) ? 1 : 0;
const int bIdx = (code==CV_YUV2BGR_NV21 || code==CV_YUV2BGRA_NV21 || code==CV_YUV2BGR_NV12 || code==CV_YUV2BGRA_NV12) ? 0 : 2;
const int uIdx = (code==CV_YUV2BGR_NV21 || code==CV_YUV2BGRA_NV21 || code==CV_YUV2RGB_NV21 || code==CV_YUV2RGBA_NV21) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U );
@ -3524,7 +3524,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
const uchar* y = src.ptr();
const uchar* uv = y + srcstep * dstSz.height;
switch(dcn*100 + bidx * 10 + uidx)
switch(dcn*100 + bIdx * 10 + uIdx)
{
case 300: cvtYUV420sp2RGB<0, 0> (dst, srcstep, y, uv); break;
case 301: cvtYUV420sp2RGB<0, 1> (dst, srcstep, y, uv); break;
@ -3545,8 +3545,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
//http://www.fourcc.org/yuv.php#IYUV == I420 -> It comprises an NxN Y plane followed by (N/2)x(N/2) U and V planes
if (dcn <= 0) dcn = (code==CV_YUV2BGRA_YV12 || code==CV_YUV2RGBA_YV12 || code==CV_YUV2RGBA_IYUV || code==CV_YUV2BGRA_IYUV) ? 4 : 3;
const int bidx = (code==CV_YUV2BGR_YV12 || code==CV_YUV2BGRA_YV12 || code==CV_YUV2BGR_IYUV || code==CV_YUV2BGRA_IYUV) ? 0 : 2;
const int uidx = (code==CV_YUV2BGR_YV12 || code==CV_YUV2RGB_YV12 || code==CV_YUV2BGRA_YV12 || code==CV_YUV2RGBA_YV12) ? 1 : 0;
const int bIdx = (code==CV_YUV2BGR_YV12 || code==CV_YUV2BGRA_YV12 || code==CV_YUV2BGR_IYUV || code==CV_YUV2BGRA_IYUV) ? 0 : 2;
const int uIdx = (code==CV_YUV2BGR_YV12 || code==CV_YUV2RGB_YV12 || code==CV_YUV2BGRA_YV12 || code==CV_YUV2RGBA_YV12) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U );
@ -3563,9 +3563,9 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
int ustepIdx = 0;
int vstepIdx = dstSz.height % 4 == 2 ? 1 : 0;
if(uidx == 1) { std::swap(u ,v), std::swap(ustepIdx, vstepIdx); };
if(uIdx == 1) { std::swap(u ,v), std::swap(ustepIdx, vstepIdx); };
switch(dcn*10 + bidx)
switch(dcn*10 + bIdx)
{
case 30: cvtYUV420p2RGB<0>(dst, srcstep, y, u, v, ustepIdx, vstepIdx); break;
case 32: cvtYUV420p2RGB<2>(dst, srcstep, y, u, v, ustepIdx, vstepIdx); break;
@ -3598,9 +3598,9 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
//http://www.fourcc.org/yuv.php#YVYU
if (dcn <= 0) dcn = (code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2RGBA_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 4 : 3;
const int bidx = (code==CV_YUV2BGR_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2BGR_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2BGR_YVYU || code==CV_YUV2BGRA_YVYU) ? 0 : 2;
const int ycn = (code==CV_YUV2RGB_UYVY || code==CV_YUV2BGR_UYVY || code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY) ? 1 : 0;
const int uidx = (code==CV_YUV2RGB_YVYU || code==CV_YUV2BGR_YVYU || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 1 : 0;
const int bIdx = (code==CV_YUV2BGR_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2BGR_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2BGR_YVYU || code==CV_YUV2BGRA_YVYU) ? 0 : 2;
const int ycn = (code==CV_YUV2RGB_UYVY || code==CV_YUV2BGR_UYVY || code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY) ? 1 : 0;
const int uIdx = (code==CV_YUV2RGB_YVYU || code==CV_YUV2BGR_YVYU || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( scn == 2 && depth == CV_8U );
@ -3608,7 +3608,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
_dst.create(sz, CV_8UC(dcn));
dst = _dst.getMat();
switch(dcn*1000 + bidx*100 + uidx*10 + ycn)
switch(dcn*1000 + bIdx*100 + uIdx*10 + ycn)
{
case 3000: cvtYUV422toRGB<0,0,0>(dst, (int)src.step, src.ptr<uchar>()); break;
case 3001: cvtYUV422toRGB<0,0,1>(dst, (int)src.step, src.ptr<uchar>()); break;

View File

@ -311,10 +311,10 @@ int FilterEngine::start(const Mat& src, const Rect& _srcRoi,
srcRoi.y + srcRoi.height <= src.rows );
Point ofs;
Size wholeSize(src.cols, src.rows);
Size wsz(src.cols, src.rows);
if( !isolated )
src.locateROI( wholeSize, ofs );
start( wholeSize, srcRoi + ofs, maxBufRows );
src.locateROI( wsz, ofs );
start( wsz, srcRoi + ofs, maxBufRows );
return startY - ofs.y;
}
@ -2427,7 +2427,7 @@ template<class CastOp, class VecOp> struct ColumnFilter : public BaseColumnFilte
{
DT* D = (DT*)dst;
i = vecOp(src, dst, width);
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST f = ky[0];
@ -2610,7 +2610,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
{
if( is_1_2_1 )
{
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta;
@ -2624,7 +2624,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0);
@ -2633,7 +2633,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
}
else if( is_1_m2_1 )
{
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta;
@ -2647,7 +2647,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0);
@ -2700,7 +2700,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S2[i] - S0[i] + _delta;
D[i] = castOp(s0);

View File

@ -290,14 +290,14 @@ TWeight GCGraph<TWeight>::maxFlow()
curr_ts++;
while( !orphans.empty() )
{
Vtx* v = orphans.back();
Vtx* v2 = orphans.back();
orphans.pop_back();
int d, minDist = INT_MAX;
e0 = 0;
vt = v->t;
vt = v2->t;
for( ei = v->first; ei != 0; ei = edgePtr[ei].next )
for( ei = v2->first; ei != 0; ei = edgePtr[ei].next )
{
if( edgePtr[ei^(vt^1)].weight == 0 )
continue;
@ -344,16 +344,16 @@ TWeight GCGraph<TWeight>::maxFlow()
}
}
if( (v->parent = e0) > 0 )
if( (v2->parent = e0) > 0 )
{
v->ts = curr_ts;
v->dist = minDist;
v2->ts = curr_ts;
v2->dist = minDist;
continue;
}
/* no parent is found */
v->ts = 0;
for( ei = v->first; ei != 0; ei = edgePtr[ei].next )
v2->ts = 0;
for( ei = v2->first; ei != 0; ei = edgePtr[ei].next )
{
u = vtxPtr+edgePtr[ei].dst;
ej = u->parent;
@ -364,7 +364,7 @@ TWeight GCGraph<TWeight>::maxFlow()
u->next = nilNode;
last = last->next = u;
}
if( ej > 0 && vtxPtr+edgePtr[ej].dst == v )
if( ej > 0 && vtxPtr+edgePtr[ej].dst == v2 )
{
orphans.push_back(u);
u->parent = ORPHAN;

View File

@ -7,8 +7,8 @@
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
@ -198,9 +198,9 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe
{
for( i = 0; i < dims; i++ )
{
size_t j, n = histSize[i];
for( j = 0; j < n; j++ )
CV_Assert( ranges[i][j] < ranges[i][j+1] );
size_t n = histSize[i];
for(size_t k = 0; k < n; k++ )
CV_Assert( ranges[i][k] < ranges[i][k+1] );
}
}
}
@ -431,7 +431,7 @@ calcHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
uchar** ptrs = &_ptrs[0];
const int* deltas = &_deltas[0];
uchar* H = hist.data;
int i, x;
int x;
const uchar* mask = _ptrs[dims];
int mstep = _deltas[dims*2 + 1];
vector<size_t> _tab;
@ -480,7 +480,7 @@ calcHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
matH[*p0]++;
}
for( i = 0; i < 256; i++ )
for(int i = 0; i < 256; i++ )
{
size_t hidx = tab[i];
if( hidx < OUT_OF_RANGE )
@ -548,7 +548,8 @@ calcHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
for( x = 0; x < imsize.width; x++ )
{
uchar* Hptr = H;
for( i = 0; i < dims; i++ )
int i = 0;
for( ; i < dims; i++ )
{
size_t idx = tab[*ptrs[i] + i*256];
if( idx >= OUT_OF_RANGE )
@ -584,7 +585,7 @@ calcHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
for( ; i < dims; i++ )
ptrs[i] += deltas[i*2];
}
for( i = 0; i < dims; i++ )
for(int i = 0; i < dims; i++ )
ptrs[i] += deltas[i*2 + 1];
}
}
@ -729,7 +730,7 @@ calcSparseHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
{
uchar** ptrs = (uchar**)&_ptrs[0];
const int* deltas = &_deltas[0];
int i, x;
int x;
const uchar* mask = _ptrs[dims];
int mstep = _deltas[dims*2 + 1];
int idx[CV_MAX_DIM];
@ -759,7 +760,7 @@ calcSparseHist_8u( vector<uchar*>& _ptrs, const vector<int>& _deltas,
for( ; i < dims; i++ )
ptrs[i] += deltas[i*2];
}
for( i = 0; i < dims; i++ )
for(int i = 0; i < dims; i++ )
ptrs[i] += deltas[i*2 + 1];
}
}
@ -1583,7 +1584,7 @@ cvCreateHist( int dims, int *sizes, CvHistType type, float** ranges, int uniform
hist = (CvHistogram *)cvAlloc( sizeof( CvHistogram ));
hist->type = CV_HIST_MAGIC_VAL + ((int)type & 1);
if (uniform) hist->type|= CV_HIST_UNIFORM_FLAG;
if (uniform) hist->type|= CV_HIST_UNIFORM_FLAG;
hist->thresh2 = 0;
hist->bins = 0;
if( type == CV_HIST_ARRAY )
@ -1749,7 +1750,7 @@ cvGetMinMaxHistValue( const CvHistogram* hist,
int* idx_min, int* idx_max )
{
double minVal, maxVal;
int i, dims, size[CV_MAX_DIM];
int dims, size[CV_MAX_DIM];
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
@ -1782,9 +1783,8 @@ cvGetMinMaxHistValue( const CvHistogram* hist,
{
int imin = minPt.y*mat.cols + minPt.x;
int imax = maxPt.y*mat.cols + maxPt.x;
int i;
for( i = dims - 1; i >= 0; i-- )
for(int i = dims - 1; i >= 0; i-- )
{
if( idx_min )
{
@ -1844,7 +1844,7 @@ cvGetMinMaxHistValue( const CvHistogram* hist,
minVal = maxVal = 0;
}
for( i = 0; i < dims; i++ )
for(int i = 0; i < dims; i++ )
{
if( idx_min )
idx_min[i] = _idx_min ? _idx_min[i] : -1;

View File

@ -92,8 +92,6 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
int step, width, height;
int numangle, numrho;
int total = 0;
float ang;
int r, n;
int i, j;
float irho = 1 / rho;
double scale;
@ -117,7 +115,8 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
memset( accum, 0, sizeof(accum[0]) * (numangle+2) * (numrho+2) );
for( ang = 0, n = 0; n < numangle; ang += theta, n++ )
float ang = 0;
for(int n = 0; n < numangle; ang += theta, n++ )
{
tabSin[n] = (float)(sin(ang) * irho);
tabCos[n] = (float)(cos(ang) * irho);
@ -128,17 +127,17 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
for( j = 0; j < width; j++ )
{
if( image[i * step + j] != 0 )
for( n = 0; n < numangle; n++ )
for(int n = 0; n < numangle; n++ )
{
r = cvRound( j * tabCos[n] + i * tabSin[n] );
int r = cvRound( j * tabCos[n] + i * tabSin[n] );
r += (numrho - 1) / 2;
accum[(n+1) * (numrho+2) + r+1]++;
}
}
// stage 2. find local maximums
for( r = 0; r < numrho; r++ )
for( n = 0; n < numangle; n++ )
for(int r = 0; r < numrho; r++ )
for(int n = 0; n < numangle; n++ )
{
int base = (n+1) * (numrho+2) + r+1;
if( accum[base] > threshold &&
@ -529,7 +528,7 @@ icvHoughLinesProbabilistic( CvMat* image,
// choose random point out of the remaining ones
int idx = cvRandInt(&rng) % count;
int max_val = threshold-1, max_n = 0;
CvPoint* pt = (CvPoint*)cvGetSeqElem( seq, idx );
CvPoint* point = (CvPoint*)cvGetSeqElem( seq, idx );
CvPoint line_end[2] = {{0,0}, {0,0}};
float a, b;
int* adata = (int*)accum.data;
@ -537,11 +536,11 @@ icvHoughLinesProbabilistic( CvMat* image,
int good_line;
const int shift = 16;
i = pt->y;
j = pt->x;
i = point->y;
j = point->x;
// "remove" it by overriding it with the last element
*pt = *(CvPoint*)cvGetSeqElem( seq, count-1 );
*point = *(CvPoint*)cvGetSeqElem( seq, count-1 );
// check if it has been excluded already (i.e. belongs to some other line)
if( !mdata0[i*width + j] )
@ -852,7 +851,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
for( x = 0; x < cols; x++ )
{
float vx, vy;
int sx, sy, x0, y0, x1, y1, r, k;
int sx, sy, x0, y0, x1, y1, r;
CvPoint pt;
vx = dx_row[x];
@ -869,7 +868,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
x0 = cvRound((x*idp)*ONE);
y0 = cvRound((y*idp)*ONE);
// Step from min_radius to max_radius in both directions of the gradient
for( k = 0; k < 2; k++ )
for(int k1 = 0; k1 < 2; k1++ )
{
x1 = x0 + min_radius * sx;
y1 = y0 + min_radius * sy;
@ -934,7 +933,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
//Calculate circle's center in pixels
float cx = (float)((x + 0.5f)*dp), cy = (float)(( y + 0.5f )*dp);
float start_dist, dist_sum;
float r_best = 0, c[3];
float r_best = 0;
int max_count = 0;
// Check distance with previously detected circles
for( j = 0; j < circles->total; j++ )
@ -996,6 +995,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
// Check if the circle has enough support
if( max_count > acc_threshold )
{
float c[3];
c[0] = cx;
c[1] = cy;
c[2] = (float)r_best;

View File

@ -97,7 +97,6 @@ static inline void interpolateLanczos4( float x, float* coeffs )
static const double cs[][2]=
{{1, 0}, {-s45, -s45}, {0, 1}, {s45, -s45}, {-1, 0}, {s45, s45}, {0, -1}, {-s45, s45}};
int i;
if( x < FLT_EPSILON )
{
for( int i = 0; i < 8; i++ )
@ -108,7 +107,7 @@ static inline void interpolateLanczos4( float x, float* coeffs )
float sum = 0;
double y0=-(x+3)*CV_PI*0.25, s0 = sin(y0), c0=cos(y0);
for( i = 0; i < 8; i++ )
for(int i = 0; i < 8; i++ )
{
double y = -(x+3-i)*CV_PI*0.25;
coeffs[i] = (float)((cs[i][0]*s0 + cs[i][1]*c0)/(y*y));
@ -116,7 +115,7 @@ static inline void interpolateLanczos4( float x, float* coeffs )
}
sum = 1.f/sum;
for( i = 0; i < 8; i++ )
for(int i = 0; i < 8; i++ )
coeffs[i] *= sum;
}
@ -1091,14 +1090,14 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
const T* srows[MAX_ESIZE]={0};
WT* rows[MAX_ESIZE]={0};
int prev_sy[MAX_ESIZE];
int k, dy;
int dy;
xmin *= cn;
xmax *= cn;
HResize hresize;
VResize vresize;
for( k = 0; k < ksize; k++ )
for(int k = 0; k < ksize; k++ )
{
prev_sy[k] = -1;
rows[k] = (WT*)_buffer + bufstep*k;
@ -1107,9 +1106,9 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
// image resize is a separable operation. In case of not too strong
for( dy = 0; dy < dsize.height; dy++, beta += ksize )
{
int sy0 = yofs[dy], k, k0=ksize, k1=0, ksize2 = ksize/2;
int sy0 = yofs[dy], k0=ksize, k1=0, ksize2 = ksize/2;
for( k = 0; k < ksize; k++ )
for(int k = 0; k < ksize; k++ )
{
int sy = clip(sy0 - ksize2 + 1 + k, 0, ssize.height);
for( k1 = std::max(k1, k); k1 < ksize; k1++ )
@ -2374,25 +2373,25 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
for( i = 0; i < 8; i++, w += 8 )
{
int yi = y[i];
const T* S = S0 + yi*sstep;
const T* S1 = S0 + yi*sstep;
if( yi < 0 )
continue;
if( x[0] >= 0 )
sum += (S[x[0]] - cv)*w[0];
sum += (S1[x[0]] - cv)*w[0];
if( x[1] >= 0 )
sum += (S[x[1]] - cv)*w[1];
sum += (S1[x[1]] - cv)*w[1];
if( x[2] >= 0 )
sum += (S[x[2]] - cv)*w[2];
sum += (S1[x[2]] - cv)*w[2];
if( x[3] >= 0 )
sum += (S[x[3]] - cv)*w[3];
sum += (S1[x[3]] - cv)*w[3];
if( x[4] >= 0 )
sum += (S[x[4]] - cv)*w[4];
sum += (S1[x[4]] - cv)*w[4];
if( x[5] >= 0 )
sum += (S[x[5]] - cv)*w[5];
sum += (S1[x[5]] - cv)*w[5];
if( x[6] >= 0 )
sum += (S[x[6]] - cv)*w[6];
sum += (S1[x[6]] - cv)*w[6];
if( x[7] >= 0 )
sum += (S[x[7]] - cv)*w[7];
sum += (S1[x[7]] - cv)*w[7];
}
D[k] = castOp(sum);
}
@ -2966,8 +2965,8 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue );
else
{
Mat matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, matA, interpolation, borderType, borderValue );
Mat _matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue );
}
}
}
@ -3064,8 +3063,8 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue );
else
{
Mat matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, matA, interpolation, borderType, borderValue );
Mat _matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue );
}
}
}

View File

@ -248,7 +248,7 @@ template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* mome
typedef int WT;
typedef int MT;
cv::Size size = img.size();
int x, y;
int y;
MT mom[10] = {0,0,0,0,0,0,0,0,0,0};
bool useSIMD = cv::checkHardwareSupport(CV_CPU_SSE2);
@ -312,7 +312,7 @@ template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* mome
mom[0] += x0; // m00
}
for( x = 0; x < 10; x++ )
for(int x = 0; x < 10; x++ )
moments[x] = (double)mom[x];
}

View File

@ -287,7 +287,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
*_radius = 0;
CvSeqReader reader;
int i, k, count;
int k, count;
CvPoint2D32f pts[8];
CvContour contour_header;
CvSeqBlock block;
@ -324,7 +324,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
pt_left = pt_right = pt_top = pt_bottom = (CvPoint *)(reader.ptr);
CV_READ_SEQ_ELEM( pt, reader );
for( i = 1; i < count; i++ )
for(int i = 1; i < count; i++ )
{
CvPoint* pt_ptr = (CvPoint*)reader.ptr;
CV_READ_SEQ_ELEM( pt, reader );
@ -351,7 +351,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
pt_left = pt_right = pt_top = pt_bottom = (CvPoint2D32f *) (reader.ptr);
CV_READ_SEQ_ELEM( pt, reader );
for( i = 1; i < count; i++ )
for(int i = 1; i < count; i++ )
{
CvPoint2D32f* pt_ptr = (CvPoint2D32f*)reader.ptr;
CV_READ_SEQ_ELEM( pt, reader );
@ -375,14 +375,14 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
for( k = 0; k < max_iters; k++ )
{
double min_delta = 0, delta;
CvPoint2D32f ptfl, farAway = { 0, 0};
/*only for first iteration because the alg is repared at the loop's foot*/
if(k==0)
icvFindEnslosingCicle4pts_32f( pts, &center, &radius );
CvPoint2D32f ptfl, farAway = { 0, 0};
/*only for first iteration because the alg is repared at the loop's foot*/
if(k==0)
icvFindEnslosingCicle4pts_32f( pts, &center, &radius );
cvStartReadSeq( sequence, &reader, 0 );
for( i = 0; i < count; i++ )
for(int i = 0; i < count; i++ )
{
if( !is_float )
{
@ -406,22 +406,22 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
if( result )
break;
CvPoint2D32f ptsCopy[4];
/* find good replacement partner for the point which is at most far away,
starting with the one that lays in the actual circle (i=3) */
for(int i = 3; i >=0; i-- )
{
for(int j = 0; j < 4; j++ )
{
ptsCopy[j]=(i != j)? pts[j]: farAway;
}
CvPoint2D32f ptsCopy[4];
/* find good replacement partner for the point which is at most far away,
starting with the one that lays in the actual circle (i=3) */
for(int i = 3; i >=0; i-- )
{
for(int j = 0; j < 4; j++ )
{
ptsCopy[j]=(i != j)? pts[j]: farAway;
}
icvFindEnslosingCicle4pts_32f(ptsCopy, &center, &radius );
if( icvIsPtInCircle( pts[i], center, radius )>=0){ // replaced one again in the new circle?
pts[i] = farAway;
break;
}
}
icvFindEnslosingCicle4pts_32f(ptsCopy, &center, &radius );
if( icvIsPtInCircle( pts[i], center, radius )>=0){ // replaced one again in the new circle?
pts[i] = farAway;
break;
}
}
}
if( !result )
@ -429,7 +429,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
cvStartReadSeq( sequence, &reader, 0 );
radius = 0.f;
for( i = 0; i < count; i++ )
for(int i = 0; i < count; i++ )
{
CvPoint2D32f ptfl;
float t, dx, dy;
@ -799,7 +799,7 @@ cvFitEllipse2( const CvArr* array )
CV_Error( CV_StsBadSize, "Number of points should be >= 5" );
/*
* New fitellipse algorithm, contributed by Dr. Daniel Weiss
* New fitellipse algorithm, contributed by Dr. Daniel Weiss
*/
CvPoint2D32f c = {0,0};
double gfp[5], rp[5], t;

View File

@ -500,8 +500,8 @@ float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeff
Point2f dcenter((destImageWidth-1)*0.5f, 0.f);
float xmin = FLT_MAX, xmax = -FLT_MAX, ymin = FLT_MAX, ymax = -FLT_MAX;
int N = 9;
std::vector<Point2f> u(1), v(1);
Mat _u(u), I = Mat::eye(3,3,CV_64F);
std::vector<Point2f> uvec(1), vvec(1);
Mat I = Mat::eye(3,3,CV_64F);
float alpha = (float)_alpha;
int ndcoeffs = distCoeffs0.cols*distCoeffs0.rows*distCoeffs0.channels();
@ -517,9 +517,9 @@ float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeff
for( int j = 0; j < N; j++ )
{
Point2f p((float)j*imageSize.width/(N-1), (float)i*imageSize.height/(N-1));
u[0] = p;
undistortPoints(_u, v, cameraMatrix, distCoeffs, I, I);
Point2f q = mapPointSpherical(v[0], alpha, 0, projType);
uvec[0] = p;
undistortPoints(uvec, vvec, cameraMatrix, distCoeffs, I, I);
Point2f q = mapPointSpherical(vvec[0], alpha, 0, projType);
if( xmin > q.x ) xmin = q.x;
if( xmax < q.x ) xmax = q.x;
if( ymin > q.y ) ymin = q.y;

View File

@ -266,7 +266,7 @@ void CV_FindContourTest::run_func()
// the whole testing is done here, run_func() is not utilized in this test
int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
{
int i, code = cvtest::TS::OK;
int code = cvtest::TS::OK;
cvCmpS( img[0], 0, img[0], CV_CMP_GT );
@ -303,7 +303,7 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
CvTreeNodeIterator iterator2;
int count3;
for( i = 0; i < 2; i++ )
for(int i = 0; i < 2; i++ )
{
CvTreeNodeIterator iterator;
cvInitTreeNodeIterator( &iterator, i == 0 ? contours : contours2, INT_MAX );
@ -353,7 +353,7 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
goto _exit_;
}
for( i = 0; i < seq1->total; i++ )
for(int i = 0; i < seq1->total; i++ )
{
CvPoint pt1;
CvPoint pt2;

View File

@ -254,7 +254,7 @@ int CV_BaseShapeDescrTest::read_params( CvFileStorage* fs )
}
void CV_BaseShapeDescrTest::generate_point_set( void* points )
void CV_BaseShapeDescrTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, k, n, total, point_type;
@ -269,16 +269,16 @@ void CV_BaseShapeDescrTest::generate_point_set( void* points )
}
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_SEQ_ELTYPE(ptseq);
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_TYPE(ptm->type);
@ -614,16 +614,16 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx )
for( i = 0; i < point_count; i++ )
{
int idx = 0, on_edge = 0;
double result = cvTsPointPolygonTest( p[i], h, hull_count, &idx, &on_edge );
double pptresult = cvTsPointPolygonTest( p[i], h, hull_count, &idx, &on_edge );
if( result < 0 )
if( pptresult < 0 )
{
ts->printf( cvtest::TS::LOG, "The point #%d is outside of the convex hull\n", i );
code = cvtest::TS::FAIL_BAD_ACCURACY;
goto _exit_;
}
if( result < FLT_EPSILON && !on_edge )
if( pptresult < FLT_EPSILON && !on_edge )
mask->data.ptr[idx] = (uchar)1;
}
@ -735,15 +735,15 @@ int CV_MinAreaRectTest::validate_test_results( int test_case_idx )
for( i = 0; i < point_count; i++ )
{
int idx = 0, on_edge = 0;
double result = cvTsPointPolygonTest( p[i], box_pt, 4, &idx, &on_edge );
if( result < -eps )
double pptresult = cvTsPointPolygonTest( p[i], box_pt, 4, &idx, &on_edge );
if( pptresult < -eps )
{
ts->printf( cvtest::TS::LOG, "The point #%d is outside of the box\n", i );
code = cvtest::TS::FAIL_BAD_ACCURACY;
goto _exit_;
}
if( result < eps )
if( pptresult < eps )
{
for( j = 0; j < 4; j++ )
{
@ -997,7 +997,7 @@ CV_FitEllipseTest::CV_FitEllipseTest()
}
void CV_FitEllipseTest::generate_point_set( void* points )
void CV_FitEllipseTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, total, point_type;
@ -1020,16 +1020,16 @@ void CV_FitEllipseTest::generate_point_set( void* points )
}
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_SEQ_ELTYPE(ptseq);
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_TYPE(ptm->type);
@ -1226,7 +1226,7 @@ CV_FitLineTest::CV_FitLineTest()
}
void CV_FitLineTest::generate_point_set( void* points )
void CV_FitLineTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, k, n, total, point_type;
@ -1250,16 +1250,16 @@ void CV_FitLineTest::generate_point_set( void* points )
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_MAT_DEPTH(CV_SEQ_ELTYPE(ptseq));
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_DEPTH(CV_MAT_TYPE(ptm->type));
@ -1498,7 +1498,7 @@ CV_ContourMomentsTest::CV_ContourMomentsTest()
}
void CV_ContourMomentsTest::generate_point_set( void* points )
void CV_ContourMomentsTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
float max_sz;
@ -1518,7 +1518,7 @@ void CV_ContourMomentsTest::generate_point_set( void* points )
max_r_scale = cvtest::randReal(rng)*max_max_r_scale*0.01;
angle = cvtest::randReal(rng)*360;
cvTsGenerateTousledBlob( center, axes, max_r_scale, angle, points, rng );
cvTsGenerateTousledBlob( center, axes, max_r_scale, angle, pointsSet, rng );
if( points1 )
points1->flags = CV_SEQ_MAGIC_VAL + CV_SEQ_POLYGON;

View File

@ -253,46 +253,46 @@ void CV_MorphologyBaseTest::prepare_to_validation( int /*test_case_idx*/ )
Mat _ielement(element->nRows, element->nCols, CV_32S, element->values);
Mat _element;
_ielement.convertTo(_element, CV_8U);
Point anchor(element->anchorX, element->anchorY);
int border = BORDER_REPLICATE;
Point _anchor(element->anchorX, element->anchorY);
int _border = BORDER_REPLICATE;
if( optype == CV_MOP_ERODE )
{
cvtest::erode( src, dst, _element, anchor, border );
cvtest::erode( src, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_DILATE )
{
cvtest::dilate( src, dst, _element, anchor, border );
cvtest::dilate( src, dst, _element, _anchor, _border );
}
else
{
Mat temp;
if( optype == CV_MOP_OPEN )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( temp, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( temp, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_CLOSE )
{
cvtest::dilate( src, temp, _element, anchor, border );
cvtest::erode( temp, dst, _element, anchor, border );
cvtest::dilate( src, temp, _element, _anchor, _border );
cvtest::erode( temp, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_GRADIENT )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( src, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( src, dst, _element, _anchor, _border );
cvtest::add( dst, 1, temp, -1, Scalar::all(0), dst, dst.type() );
}
else if( optype == CV_MOP_TOPHAT )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( temp, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( temp, dst, _element, _anchor, _border );
cvtest::add( src, 1, dst, -1, Scalar::all(0), dst, dst.type() );
}
else if( optype == CV_MOP_BLACKHAT )
{
cvtest::dilate( src, temp, _element, anchor, border );
cvtest::erode( temp, dst, _element, anchor, border );
cvtest::dilate( src, temp, _element, _anchor, _border );
cvtest::erode( temp, dst, _element, _anchor, _border );
cvtest::add( dst, 1, src, -1, Scalar::all(0), dst, dst.type() );
}
else

View File

@ -94,7 +94,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
RNG& rng = ts->get_rng();
int depth, cn;
int i;
double buf[8];
double buff[8];
cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
depth = cvtest::randInt(rng) % 3;
@ -127,7 +127,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
l_diff = u_diff = Scalar::all(0.);
else
{
Mat m( 1, 8, CV_16S, buf );
Mat m( 1, 8, CV_16S, buff );
rng.fill( m, RNG::NORMAL, Scalar::all(0), Scalar::all(32) );
for( i = 0; i < 4; i++ )
{

View File

@ -255,13 +255,13 @@ void CV_BaseHistTest::init_hist( int /*test_case_idx*/, int hist_i )
else
{
CvArr* arr = hist[hist_i]->bins;
int i, j, total_size = 1, nz_count;
int i, j, totalSize = 1, nz_count;
int idx[CV_MAX_DIM];
for( i = 0; i < cdims; i++ )
total_size *= dims[i];
totalSize *= dims[i];
nz_count = cvtest::randInt(rng) % MAX( total_size/4, 100 );
nz_count = MIN( nz_count, total_size );
nz_count = cvtest::randInt(rng) % MAX( totalSize/4, 100 );
nz_count = MIN( nz_count, totalSize );
// a zero number of non-zero elements should be allowed
for( i = 0; i < nz_count; i++ )

View File

@ -516,8 +516,8 @@ int CV_WarpAffineTest::prepare_test_case( int test_case_idx )
if( code <= 0 )
return code;
double buf[6];
Mat tmp( 2, 3, mat.type(), buf );
double buffer[6];
Mat tmp( 2, 3, mat.type(), buffer );
center.x = (float)((cvtest::randReal(rng)*1.2 - 0.1)*src.cols);
center.y = (float)((cvtest::randReal(rng)*1.2 - 0.1)*src.rows);
@ -636,17 +636,17 @@ int CV_WarpPerspectiveTest::prepare_test_case( int test_case_idx )
s[3] = Point2f(0,src.rows-1.f);
d[3] = Point2f(0,dst.rows-1.f);
float buf[16];
Mat tmp( 1, 16, CV_32FC1, buf );
float bufer[16];
Mat tmp( 1, 16, CV_32FC1, bufer );
rng.fill( tmp, CV_RAND_NORMAL, Scalar::all(0.), Scalar::all(0.1) );
for( i = 0; i < 4; i++ )
{
s[i].x += buf[i*4]*src.cols/2;
s[i].y += buf[i*4+1]*src.rows/2;
d[i].x += buf[i*4+2]*dst.cols/2;
d[i].y += buf[i*4+3]*dst.rows/2;
s[i].x += bufer[i*4]*src.cols/2;
s[i].y += bufer[i*4+1]*src.rows/2;
d[i].x += bufer[i*4+2]*dst.cols/2;
d[i].y += bufer[i*4+3]*dst.rows/2;
}
cv::getPerspectiveTransform( s, d ).convertTo( mat, mat.depth() );
@ -806,15 +806,15 @@ protected:
void fill_array( int test_case_idx, int i, int j, Mat& arr );
private:
bool useCPlus;
cv::Mat input0;
cv::Mat input1;
cv::Mat input2;
cv::Mat input_new_cam;
cv::Mat input_output;
bool useCPlus;
cv::Mat input0;
cv::Mat input1;
cv::Mat input2;
cv::Mat input_new_cam;
cv::Mat input_output;
bool zero_new_cam;
bool zero_distortion;
bool zero_new_cam;
bool zero_distortion;
};
@ -823,7 +823,7 @@ CV_UndistortTest::CV_UndistortTest() : CV_ImgWarpBaseTest( false )
//spatial_scale_zoom = spatial_scale_decimate;
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
spatial_scale_decimate = spatial_scale_zoom;
}
@ -840,8 +840,8 @@ void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector
types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
sizes[INPUT][1] = cvSize(3,3);
sizes[INPUT][2] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4);
types[INPUT][3] = types[INPUT][1];
sizes[INPUT][3] = sizes[INPUT][1];
types[INPUT][3] = types[INPUT][1];
sizes[INPUT][3] = sizes[INPUT][1];
interpolation = CV_INTER_LINEAR;
}
@ -855,22 +855,22 @@ void CV_UndistortTest::fill_array( int test_case_idx, int i, int j, Mat& arr )
void CV_UndistortTest::run_func()
{
if (!useCPlus)
{
if (!useCPlus)
{
CvMat a = test_mat[INPUT][1], k = test_mat[INPUT][2];
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
}
else
{
if (zero_distortion)
{
cv::undistort(input0,input_output,input1,cv::Mat());
}
else
{
cv::undistort(input0,input_output,input1,input2);
}
}
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
}
else
{
if (zero_distortion)
{
cv::undistort(input0,input_output,input1,cv::Mat());
}
else
{
cv::undistort(input0,input_output,input1,input2);
}
}
}
@ -888,10 +888,10 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
const Mat& src = test_mat[INPUT][0];
double k[4], a[9] = {0,0,0,0,0,0,0,0,1};
double new_cam[9] = {0,0,0,0,0,0,0,0,1};
double new_cam[9] = {0,0,0,0,0,0,0,0,1};
double sz = MAX(src.rows, src.cols);
Mat& _new_cam0 = test_mat[INPUT][3];
Mat& _new_cam0 = test_mat[INPUT][3];
Mat _new_cam(test_mat[INPUT][3].rows,test_mat[INPUT][3].cols,CV_64F,new_cam);
Mat& _a0 = test_mat[INPUT][1];
Mat _a(3,3,CV_64F,a);
@ -925,21 +925,21 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
_a.convertTo(_a0, _a0.depth());
zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true;
zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true;
_k.convertTo(_k0, _k0.depth());
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
_new_cam.convertTo(_new_cam0, _new_cam0.depth());
//Testing C++ code
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
if (useCPlus)
{
input0 = test_mat[INPUT][0];
input1 = test_mat[INPUT][1];
input2 = test_mat[INPUT][2];
input_new_cam = test_mat[INPUT][3];
}
//Testing C++ code
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
if (useCPlus)
{
input0 = test_mat[INPUT][0];
input1 = test_mat[INPUT][1];
input2 = test_mat[INPUT][2];
input_new_cam = test_mat[INPUT][3];
}
return code;
}
@ -947,11 +947,11 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
void CV_UndistortTest::prepare_to_validation( int /*test_case_idx*/ )
{
if (useCPlus)
{
if (useCPlus)
{
Mat& output = test_mat[INPUT_OUTPUT][0];
input_output.convertTo(output, output.type());
}
}
Mat& src = test_mat[INPUT][0];
Mat& dst = test_mat[REF_INPUT_OUTPUT][0];
Mat& dst0 = test_mat[INPUT_OUTPUT][0];
@ -978,7 +978,7 @@ protected:
void fill_array( int test_case_idx, int i, int j, Mat& arr );
private:
bool dualChannel;
bool dualChannel;
};
@ -1003,7 +1003,7 @@ void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vec
CvSize sz = sizes[OUTPUT][0];
types[INPUT][0] = types[INPUT][1] = depth;
dualChannel = cvtest::randInt(rng)%2 == 0;
dualChannel = cvtest::randInt(rng)%2 == 0;
types[OUTPUT][0] = types[OUTPUT][1] =
types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32F;
sizes[INPUT][0] = cvSize(3,3);
@ -1027,10 +1027,10 @@ void CV_UndistortMapTest::run_func()
{
CvMat a = test_mat[INPUT][0], k = test_mat[INPUT][1];
if (!dualChannel )
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
else
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], 0 );
if (!dualChannel )
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
else
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], 0 );
}
@ -1069,11 +1069,11 @@ int CV_UndistortMapTest::prepare_test_case( int test_case_idx )
_a.convertTo(_a0, _a0.depth());
_k.convertTo(_k0, _k0.depth());
if (dualChannel)
{
if (dualChannel)
{
test_mat[REF_OUTPUT][1] = Scalar::all(0);
test_mat[OUTPUT][1] = Scalar::all(0);
}
test_mat[OUTPUT][1] = Scalar::all(0);
}
return code;
}

View File

@ -91,7 +91,8 @@ void CV_ThreshTest::get_test_array_types_and_sizes( int test_case_idx,
}
else if( depth == CV_16S )
{
float min_val = SHRT_MIN-100.f, max_val = SHRT_MAX+100.f;
float min_val = SHRT_MIN-100.f;
max_val = SHRT_MAX+100.f;
thresh_val = (float)(cvtest::randReal(rng)*(max_val - min_val) + min_val);
max_val = (float)(cvtest::randReal(rng)*(max_val - min_val) + min_val);
if( cvtest::randInt(rng)%4 == 0 )

View File

@ -1347,9 +1347,9 @@ class CV_EXPORTS CvImage
{
public:
CvImage() : image(0), refcount(0) {}
CvImage( CvSize size, int depth, int channels )
CvImage( CvSize _size, int _depth, int _channels )
{
image = cvCreateImage( size, depth, channels );
image = cvCreateImage( _size, _depth, _channels );
refcount = image ? new int(1) : 0;
}
@ -1383,12 +1383,12 @@ public:
CvImage clone() { return CvImage(image ? cvCloneImage(image) : 0); }
void create( CvSize size, int depth, int channels )
void create( CvSize _size, int _depth, int _channels )
{
if( !image || !refcount ||
image->width != size.width || image->height != size.height ||
image->depth != depth || image->nChannels != channels )
attach( cvCreateImage( size, depth, channels ));
image->width != _size.width || image->height != _size.height ||
image->depth != _depth || image->nChannels != _channels )
attach( cvCreateImage( _size, _depth, _channels ));
}
void release() { detach(); }
@ -1447,9 +1447,9 @@ public:
int coi() const { return !image || !image->roi ? 0 : image->roi->coi; }
void set_roi(CvRect roi) { cvSetImageROI(image,roi); }
void set_roi(CvRect _roi) { cvSetImageROI(image,_roi); }
void reset_roi() { cvResetImageROI(image); }
void set_coi(int coi) { cvSetImageCOI(image,coi); }
void set_coi(int _coi) { cvSetImageCOI(image,_coi); }
int depth() const { return image ? image->depth : 0; }
int channels() const { return image ? image->nChannels : 0; }
int pix_size() const { return image ? ((image->depth & 255)>>3)*image->nChannels : 0; }
@ -1511,18 +1511,18 @@ class CV_EXPORTS CvMatrix
{
public:
CvMatrix() : matrix(0) {}
CvMatrix( int rows, int cols, int type )
{ matrix = cvCreateMat( rows, cols, type ); }
CvMatrix( int _rows, int _cols, int _type )
{ matrix = cvCreateMat( _rows, _cols, _type ); }
CvMatrix( int rows, int cols, int type, CvMat* hdr,
void* data=0, int step=CV_AUTOSTEP )
{ matrix = cvInitMatHeader( hdr, rows, cols, type, data, step ); }
CvMatrix( int _rows, int _cols, int _type, CvMat* hdr,
void* _data=0, int _step=CV_AUTOSTEP )
{ matrix = cvInitMatHeader( hdr, _rows, _cols, _type, _data, _step ); }
CvMatrix( int rows, int cols, int type, CvMemStorage* storage, bool alloc_data=true );
CvMatrix( int rows, int cols, int type, void* data, int step=CV_AUTOSTEP )
{ matrix = cvCreateMatHeader( rows, cols, type );
cvSetData( matrix, data, step ); }
CvMatrix( int _rows, int _cols, int _type, void* _data, int _step=CV_AUTOSTEP )
{ matrix = cvCreateMatHeader( _rows, _cols, _type );
cvSetData( matrix, _data, _step ); }
CvMatrix( CvMat* m )
{ matrix = m; }
@ -1557,12 +1557,12 @@ public:
addref();
}
void create( int rows, int cols, int type )
void create( int _rows, int _cols, int _type )
{
if( !matrix || !matrix->refcount ||
matrix->rows != rows || matrix->cols != cols ||
CV_MAT_TYPE(matrix->type) != type )
set( cvCreateMat( rows, cols, type ), false );
matrix->rows != _rows || matrix->cols != _cols ||
CV_MAT_TYPE(matrix->type) != _type )
set( cvCreateMat( _rows, _cols, _type ), false );
}
void addref() const
@ -1626,8 +1626,8 @@ public:
const uchar* data() const { return matrix ? matrix->data.ptr : 0; }
int step() const { return matrix ? matrix->step : 0; }
void set_data( void* data, int step=CV_AUTOSTEP )
{ cvSetData( matrix, data, step ); }
void set_data( void* _data, int _step=CV_AUTOSTEP )
{ cvSetData( matrix, _data, _step ); }
uchar* row(int i) { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
const uchar* row(int i) const
@ -2014,8 +2014,8 @@ struct CV_EXPORTS BaseKeypoint
: x(0), y(0), image(NULL)
{}
BaseKeypoint(int x, int y, IplImage* image)
: x(x), y(y), image(image)
BaseKeypoint(int _x, int _y, IplImage* _image)
: x(_x), y(_y), image(_image)
{}
};

View File

@ -350,11 +350,10 @@ public:
virtual void Process(IplImage* pImg, IplImage* /*pFG*/)
{
int i;
double MinTv = pImg->width/1440.0; /* minimal threshold for speed difference */
double MinTv2 = MinTv*MinTv;
for(i=m_Tracks.GetBlobNum(); i>0; --i)
for(int i=m_Tracks.GetBlobNum(); i>0; --i)
{
DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlob(i-1);
pF->state = 0;
@ -466,14 +465,13 @@ public:
if(m_Wnd)
{ /* Debug output: */
int i;
if(m_pDebugImg==NULL)
m_pDebugImg = cvCloneImage(pImg);
else
cvCopy(pImg, m_pDebugImg);
for(i=m_TrackDataBase.GetBlobNum(); i>0; --i)
for(int i=m_TrackDataBase.GetBlobNum(); i>0; --i)
{ /* Draw all elements in track data base: */
int j;
DefTrackForDist* pF = (DefTrackForDist*)m_TrackDataBase.GetBlob(i-1);
@ -497,7 +495,7 @@ public:
pF->close = 0;
} /* Draw all elements in track data base. */
for(i=m_Tracks.GetBlobNum(); i>0; --i)
for(int i=m_Tracks.GetBlobNum(); i>0; --i)
{ /* Draw all elements for all trajectories: */
DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlob(i-1);
int j;

View File

@ -301,8 +301,8 @@ public:
{ /* Find a neighbour on current frame
* for each blob from previous frame:
*/
CvBlob* pB = m_BlobList.GetBlob(i-1);
DefBlobTracker* pBT = (DefBlobTracker*)pB;
CvBlob* pBl = m_BlobList.GetBlob(i-1);
DefBlobTracker* pBT = (DefBlobTracker*)pBl;
//int BlobID = CV_BLOB_ID(pB);
//CvBlob* pBBest = NULL;
//double DistBest = -1;

View File

@ -93,18 +93,19 @@ class CvKDTreeWrap : public CvFeatureTree {
assert(results->cols == k);
assert(dist->cols == k);
for (int j = 0; j < d->rows; ++j) {
const typename __treetype::scalar_type* dj =
(const typename __treetype::scalar_type*) dptr;
for (int j = 0; j < d->rows; ++j)
{
const typename __treetype::scalar_type* dj = (const typename __treetype::scalar_type*) dptr;
int* resultsj = (int*) resultsptr;
double* distj = (double*) distptr;
tr->find_nn_bbf(dj, k, emax, nn);
assert((int)nn.size() <= k);
for (unsigned int j = 0; j < nn.size(); ++j) {
*resultsj++ = *nn[j].p;
*distj++ = nn[j].dist;
for (unsigned int i = 0; i < nn.size(); ++i)
{
*resultsj++ = *nn[i].p;
*distj++ = nn[i].dist;
}
std::fill(resultsj, resultsj + k - nn.size(), -1);
std::fill(distj, distj + k - nn.size(), 0);

View File

@ -170,12 +170,7 @@ struct CV_EXPORTS_W_MAP CvParamGrid
min_val = max_val = step = 0;
}
CvParamGrid( double min_val, double max_val, double log_step )
{
this->min_val = min_val;
this->max_val = max_val;
step = log_step;
}
CvParamGrid( double min_val, double max_val, double log_step );
//CvParamGrid( int param_id );
bool check() const;
@ -184,6 +179,13 @@ struct CV_EXPORTS_W_MAP CvParamGrid
CV_PROP_RW double step;
};
inline CvParamGrid::CvParamGrid( double _min_val, double _max_val, double _log_step )
{
min_val = _min_val;
max_val = _max_val;
step = _log_step;
}
class CV_EXPORTS_W CvNormalBayesClassifier : public CvStatModel
{
public:
@ -1829,7 +1831,7 @@ protected:
// RESULT
*/
virtual void read_params( CvFileStorage* fs, CvFileNode* fnode );
int get_len(const CvMat* mat) const;
int get_len(const CvMat* mat) const;
CvDTreeTrainData* data;
@ -2039,8 +2041,8 @@ public:
const CvMat* get_responses();
const CvMat* get_missing() const;
void set_header_lines_number( int n );
int get_header_lines_number() const;
void set_header_lines_number( int n );
int get_header_lines_number() const;
void set_response_idx( int idx ); // old response become predictors, new response_idx = idx
// if idx < 0 there will be no response
@ -2093,7 +2095,7 @@ protected:
CvMat* var_idx_out; // mat
CvMat* var_types_out; // mat
int header_lines_number;
int header_lines_number;
int response_idx;

View File

@ -1087,7 +1087,7 @@ struct rprop_loop {
for(int si = range.begin(); si < range.end(); si++ )
{
if (si % dcount0 != 0) continue;
int n1, n2, j, k;
int n1, n2, k;
double* w;
CvMat _w, _dEdw, hdr1, hdr2, ghdr1, ghdr2, _df;
CvMat *x1, *x2, *grad1, *grad2, *temp;
@ -1100,21 +1100,21 @@ struct rprop_loop {
// grab and preprocess input data
if( x0->type == CV_32F )
{
{
for(int i = 0; i < dcount; i++ )
{
const float* x0data = x0->data.fl[si+i];
double* xdata = x[0]+i*ivcount;
for( j = 0; j < ivcount; j++ )
for(int j = 0; j < ivcount; j++ )
xdata[j] = x0data[j]*w[j*2] + w[j*2+1];
}
}
}
else
for(int i = 0; i < dcount; i++ )
{
const double* x0data = x0->data.db[si+i];
double* xdata = x[0]+i*ivcount;
for( j = 0; j < ivcount; j++ )
for(int j = 0; j < ivcount; j++ )
xdata[j] = x0data[j]*w[j*2] + w[j*2+1];
}
cvInitMatHeader( x1, dcount, ivcount, CV_64F, x[0] );
@ -1144,7 +1144,7 @@ struct rprop_loop {
double* gdata = grad1->data.db + i*ovcount;
double sweight = sw ? sw[si+i] : inv_count, E1 = 0;
for( j = 0; j < ovcount; j++ )
for(int j = 0; j < ovcount; j++ )
{
double t = udata[j]*w[j*2] + w[j*2+1] - xdata[j];
gdata[j] = t*sweight;
@ -1191,7 +1191,7 @@ struct rprop_loop {
{
double* dst = _dEdw.data.db + n1*n2;
const double* src = grad1->data.db + k*n2;
for( j = 0; j < n2; j++ )
for(int j = 0; j < n2; j++ )
dst[j] += src[j];
}
@ -1215,7 +1215,7 @@ struct rprop_loop {
int CvANN_MLP::train_rprop( CvVectors x0, CvVectors u, const double* sw )
{
const int max_buf_sz = 1 << 16;
const int max_buf_size = 1 << 16;
CvMat* dw = 0;
CvMat* dEdw = 0;
CvMat* prev_dEdw_sign = 0;
@ -1256,7 +1256,7 @@ int CvANN_MLP::train_rprop( CvVectors x0, CvVectors u, const double* sw )
cvZero( prev_dEdw_sign );
inv_count = 1./count;
dcount0 = max_buf_sz/(2*total);
dcount0 = max_buf_size/(2*total);
dcount0 = MAX( dcount0, 1 );
dcount0 = MIN( dcount0, count );
buf_sz = dcount0*(total + max_count)*2;
@ -1600,8 +1600,8 @@ CvANN_MLP::CvANN_MLP( const Mat& _layer_sizes, int _activ_func,
void CvANN_MLP::create( const Mat& _layer_sizes, int _activ_func,
double _f_param1, double _f_param2 )
{
CvMat layer_sizes = _layer_sizes;
create( &layer_sizes, _activ_func, _f_param1, _f_param2 );
CvMat cvlayer_sizes = _layer_sizes;
create( &cvlayer_sizes, _activ_func, _f_param1, _f_param2 );
}
int CvANN_MLP::train( const Mat& _inputs, const Mat& _outputs,

View File

@ -129,7 +129,7 @@ CvBoostTree::train( CvDTreeTrainData*, const CvMat* )
void
CvBoostTree::scale( double scale )
CvBoostTree::scale( double _scale )
{
CvDTreeNode* node = root;
@ -139,7 +139,7 @@ CvBoostTree::scale( double scale )
CvDTreeNode* parent;
for(;;)
{
node->value *= scale;
node->value *= _scale;
if( !node->left )
break;
node = node->left;
@ -590,7 +590,7 @@ CvBoostTree::find_split_cat_reg( CvDTreeNode* node, int vi, float init_quality,
{
R += counts[i];
rsum += sum[i];
sum[i] = fabs(counts[i]) > DBL_EPSILON ? sum[i]/counts[i] : 0;
sum[i] = fabs(counts[i]) > DBL_EPSILON ? sum[i]/counts[i] : 0;
sum_ptr[i] = sum + i;
}
@ -1088,7 +1088,7 @@ CvBoost::train( const CvMat* _train_data, int _tflag,
}
bool CvBoost::train( CvMLData* _data,
CvBoostParams params,
CvBoostParams _params,
bool update )
{
bool result = false;
@ -1105,7 +1105,7 @@ bool CvBoost::train( CvMLData* _data,
const CvMat* var_idx = _data->get_var_idx();
CV_CALL( result = train( values, CV_ROW_SAMPLE, response, var_idx,
train_sidx, var_types, missing, params, update ) );
train_sidx, var_types, missing, _params, update ) );
__END__;

View File

@ -442,15 +442,15 @@ void CvERTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
if( cv_n )
{
unsigned short* udst = 0;
int* idst = 0;
unsigned short* usdst = 0;
int* idst2 = 0;
if (is_buf_16u)
{
udst = (unsigned short*)(buf->data.s + (get_work_var_count()-1)*sample_count);
usdst = (unsigned short*)(buf->data.s + (get_work_var_count()-1)*sample_count);
for( i = vi = 0; i < sample_count; i++ )
{
udst[i] = (unsigned short)vi++;
usdst[i] = (unsigned short)vi++;
vi &= vi < cv_n ? -1 : 0;
}
@ -459,15 +459,15 @@ void CvERTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
int a = (*rng)(sample_count);
int b = (*rng)(sample_count);
unsigned short unsh = (unsigned short)vi;
CV_SWAP( udst[a], udst[b], unsh );
CV_SWAP( usdst[a], usdst[b], unsh );
}
}
else
{
idst = buf->data.i + (get_work_var_count()-1)*sample_count;
idst2 = buf->data.i + (get_work_var_count()-1)*sample_count;
for( i = vi = 0; i < sample_count; i++ )
{
idst[i] = vi++;
idst2[i] = vi++;
vi &= vi < cv_n ? -1 : 0;
}
@ -475,7 +475,7 @@ void CvERTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
{
int a = (*rng)(sample_count);
int b = (*rng)(sample_count);
CV_SWAP( idst[a], idst[b], vi );
CV_SWAP( idst2[a], idst2[b], vi );
}
}
}
@ -591,7 +591,7 @@ const int* CvERTreeTrainData::get_cat_var_data( CvDTreeNode* n, int vi, int* cat
void CvERTreeTrainData::get_vectors( const CvMat* _subsample_idx,
float* values, uchar* missing,
float* responses, bool get_class_idx )
float* _responses, bool get_class_idx )
{
CvMat* subsample_idx = 0;
CvMat* subsample_co = 0;
@ -664,7 +664,7 @@ void CvERTreeTrainData::get_vectors( const CvMat* _subsample_idx,
}
// copy responses
if( responses )
if( _responses )
{
if( is_classifier )
{
@ -675,7 +675,7 @@ void CvERTreeTrainData::get_vectors( const CvMat* _subsample_idx,
int idx = sidx ? sidx[i] : i;
int val = get_class_idx ? src[idx] :
cat_map->data.i[cat_ofs->data.i[cat_var_count]+src[idx]];
responses[i] = (float)val;
_responses[i] = (float)val;
}
}
else
@ -686,7 +686,7 @@ void CvERTreeTrainData::get_vectors( const CvMat* _subsample_idx,
for( i = 0; i < count; i++ )
{
int idx = sidx ? sidx[i] : i;
responses[i] = _values[idx];
_responses[i] = _values[idx];
}
}
}
@ -853,7 +853,7 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
const float epsilon = FLT_EPSILON*2;
const float split_delta = (1 + FLT_EPSILON) * FLT_EPSILON;
int n = node->sample_count, i;
int n = node->sample_count;
int m = data->get_num_classes();
cv::AutoBuffer<uchar> inn_buf;
@ -882,8 +882,8 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
for (; smpi < n; smpi++)
{
float ptemp = values[smpi];
int m = missing[smpi];
if (m) continue;
int ms = missing[smpi];
if (ms) continue;
if ( ptemp < pmin)
pmin = ptemp;
if ( ptemp > pmax)
@ -908,7 +908,7 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
int L = 0, R = 0;
// init arrays of class instance counters on both sides of the split
for( i = 0; i < m; i++ )
for(int i = 0; i < m; i++ )
{
lc[i] = 0;
rc[i] = 0;
@ -917,8 +917,8 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
{
int r = responses[si];
float val = values[si];
int m = missing[si];
if (m) continue;
int ms = missing[si];
if (ms) continue;
if ( val < split_val )
{
lc[r]++;
@ -944,7 +944,7 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
double L = 0, R = 0;
// init arrays of class instance counters on both sides of the split
for( i = 0; i < m; i++ )
for(int i = 0; i < m; i++ )
{
lc[i] = 0;
rc[i] = 0;
@ -953,9 +953,9 @@ CvDTreeSplit* CvForestERTree::find_split_ord_class( CvDTreeNode* node, int vi, f
{
int r = responses[si];
float val = values[si];
int m = missing[si];
int ms = missing[si];
double p = priors[r];
if (m) continue;
if (ms) continue;
if ( val < split_val )
{
lc[r] += p;
@ -1579,7 +1579,7 @@ bool CvERTrees::train( const CvMat* _train_data, int _tflag,
}
bool CvERTrees::train( CvMLData* data, CvRTParams params)
bool CvERTrees::train( CvMLData* _data, CvRTParams params)
{
bool result = false;
@ -1587,7 +1587,7 @@ bool CvERTrees::train( CvMLData* data, CvRTParams params)
__BEGIN__;
CV_CALL( result = CvRTrees::train( data, params) );
CV_CALL( result = CvRTrees::train( _data, params) );
__END__;
@ -1609,7 +1609,7 @@ bool CvERTrees::grow_forest( const CvTermCriteria term_crit )
const int dims = data->var_count;
float maximal_response = 0;
CvMat* oob_sample_votes = 0;
CvMat* oob_sample_votes = 0;
CvMat* oob_responses = 0;
float* oob_samples_perm_ptr= 0;

View File

@ -166,13 +166,13 @@ bool CvGBTrees::problem_type() const
//===========================================================================
bool
CvGBTrees::train( CvMLData* data, CvGBTreesParams params, bool update )
CvGBTrees::train( CvMLData* _data, CvGBTreesParams _params, bool update )
{
bool result;
result = train ( data->get_values(), CV_ROW_SAMPLE,
data->get_responses(), data->get_var_idx(),
data->get_train_sample_idx(), data->get_var_types(),
data->get_missing(), params, update);
result = train ( _data->get_values(), CV_ROW_SAMPLE,
_data->get_responses(), _data->get_var_idx(),
_data->get_train_sample_idx(), _data->get_var_types(),
_data->get_missing(), _params, update);
//update is not supported
return result;
}
@ -1294,12 +1294,12 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
{
float err = 0.0f;
const CvMat* sample_idx = (type == CV_TRAIN_ERROR) ?
const CvMat* _sample_idx = (type == CV_TRAIN_ERROR) ?
_data->get_train_sample_idx() :
_data->get_test_sample_idx();
const CvMat* response = _data->get_responses();
int n = sample_idx ? get_len(sample_idx) : 0;
int n = _sample_idx ? get_len(_sample_idx) : 0;
n = (type == CV_TRAIN_ERROR && n == 0) ? _data->get_values()->rows : n;
if (!n)
@ -1315,7 +1315,7 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
pred_resp = new float[n];
Sample_predictor predictor = Sample_predictor(this, pred_resp, _data->get_values(),
_data->get_missing(), sample_idx);
_data->get_missing(), _sample_idx);
//#ifdef HAVE_TBB
// tbb::parallel_for(cv::BlockedRange(0,n), predictor, tbb::auto_partitioner());
@ -1323,7 +1323,7 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
cv::parallel_for(cv::BlockedRange(0,n), predictor);
//#endif
int* sidx = sample_idx ? sample_idx->data.i : 0;
int* sidx = _sample_idx ? _sample_idx->data.i : 0;
int r_step = CV_IS_MAT_CONT(response->type) ?
1 : response->step / CV_ELEM_SIZE(response->type);
@ -1357,7 +1357,7 @@ CvGBTrees::CvGBTrees( const cv::Mat& trainData, int tflag,
const cv::Mat& responses, const cv::Mat& varIdx,
const cv::Mat& sampleIdx, const cv::Mat& varType,
const cv::Mat& missingDataMask,
CvGBTreesParams params )
CvGBTreesParams _params )
{
data = 0;
weak = 0;
@ -1371,14 +1371,14 @@ CvGBTrees::CvGBTrees( const cv::Mat& trainData, int tflag,
clear();
train(trainData, tflag, responses, varIdx, sampleIdx, varType, missingDataMask, params, false);
train(trainData, tflag, responses, varIdx, sampleIdx, varType, missingDataMask, _params, false);
}
bool CvGBTrees::train( const cv::Mat& trainData, int tflag,
const cv::Mat& responses, const cv::Mat& varIdx,
const cv::Mat& sampleIdx, const cv::Mat& varType,
const cv::Mat& missingDataMask,
CvGBTreesParams params,
CvGBTreesParams _params,
bool update )
{
CvMat _trainData = trainData, _responses = responses;
@ -1387,13 +1387,13 @@ bool CvGBTrees::train( const cv::Mat& trainData, int tflag,
return train( &_trainData, tflag, &_responses, varIdx.empty() ? 0 : &_varIdx,
sampleIdx.empty() ? 0 : &_sampleIdx, varType.empty() ? 0 : &_varType,
missingDataMask.empty() ? 0 : &_missingDataMask, params, update);
missingDataMask.empty() ? 0 : &_missingDataMask, _params, update);
}
float CvGBTrees::predict( const cv::Mat& sample, const cv::Mat& missing,
float CvGBTrees::predict( const cv::Mat& sample, const cv::Mat& _missing,
const cv::Range& slice, int k ) const
{
CvMat _sample = sample, _missing = missing;
return predict(&_sample, missing.empty() ? 0 : &_missing, 0,
CvMat _sample = sample, miss = _missing;
return predict(&_sample, _missing.empty() ? 0 : &miss, 0,
slice==cv::Range::all() ? CV_WHOLE_SEQ : cvSlice(slice.start, slice.end), k);
}

View File

@ -470,10 +470,10 @@ float CvKNearest::find_nearest( const Mat& _samples, int k, Mat* _results,
}
float CvKNearest::find_nearest( const cv::Mat& samples, int k, CV_OUT cv::Mat& results,
float CvKNearest::find_nearest( const cv::Mat& _samples, int k, CV_OUT cv::Mat& results,
CV_OUT cv::Mat& neighborResponses, CV_OUT cv::Mat& dists) const
{
return find_nearest(samples, k, &results, 0, &neighborResponses, &dists);
return find_nearest(_samples, k, &results, 0, &neighborResponses, &dists);
}
/* End of file */

View File

@ -241,13 +241,13 @@ bool CvNormalBayesClassifier::train( const CvMat* _train_data, const CvMat* _res
double* cov_data = cov->data.db + i*_var_count;
double s1val = sum1[i];
double avg1 = avg_data[i];
int count = count_data[i];
int _count = count_data[i];
for( j = 0; j <= i; j++ )
{
double avg2 = avg2_data[j];
double cov_val = prod_data[j] - avg1 * sum2[j] - avg2 * s1val + avg1 * avg2 * count;
cov_val = (count > 1) ? cov_val / (count - 1) : cov_val;
double cov_val = prod_data[j] - avg1 * sum2[j] - avg2 * s1val + avg1 * avg2 * _count;
cov_val = (_count > 1) ? cov_val / (_count - 1) : cov_val;
cov_data[j] = cov_val;
}
}

View File

@ -307,14 +307,14 @@ bool CvRTrees::train( const CvMat* _train_data, int _tflag,
return grow_forest( params.term_crit );
}
bool CvRTrees::train( CvMLData* data, CvRTParams params )
bool CvRTrees::train( CvMLData* _data, CvRTParams params )
{
const CvMat* values = data->get_values();
const CvMat* response = data->get_responses();
const CvMat* missing = data->get_missing();
const CvMat* var_types = data->get_var_types();
const CvMat* train_sidx = data->get_train_sample_idx();
const CvMat* var_idx = data->get_var_idx();
const CvMat* values = _data->get_values();
const CvMat* response = _data->get_responses();
const CvMat* missing = _data->get_missing();
const CvMat* var_types = _data->get_var_types();
const CvMat* train_sidx = _data->get_train_sample_idx();
const CvMat* var_idx = _data->get_var_idx();
return train( values, CV_ROW_SAMPLE, response, var_idx,
train_sidx, var_types, missing, params );
@ -331,7 +331,7 @@ bool CvRTrees::grow_forest( const CvTermCriteria term_crit )
const int dims = data->var_count;
float maximal_response = 0;
CvMat* oob_sample_votes = 0;
CvMat* oob_sample_votes = 0;
CvMat* oob_responses = 0;
float* oob_samples_perm_ptr= 0;
@ -701,7 +701,7 @@ float CvRTrees::predict( const CvMat* sample, const CvMat* missing ) const
float CvRTrees::predict_prob( const CvMat* sample, const CvMat* missing) const
{
if( nclasses == 2 ) //classification
if( nclasses == 2 ) //classification
{
cv::AutoBuffer<int> _votes(nclasses);
int* votes = _votes;
@ -715,10 +715,10 @@ float CvRTrees::predict_prob( const CvMat* sample, const CvMat* missing) const
++votes[class_idx];
}
return float(votes[1])/ntrees;
return float(votes[1])/ntrees;
}
else // regression
CV_Error(CV_StsBadArg, "This function works for binary classification problems only...");
CV_Error(CV_StsBadArg, "This function works for binary classification problems only...");
return -1;
}
@ -809,15 +809,15 @@ void CvRTrees::read( CvFileStorage* fs, CvFileNode* fnode )
{
// initialize active variables mask
CvMat submask1;
cvGetCols( active_var_mask, &submask1, 0, nactive_vars );
cvGetCols( active_var_mask, &submask1, 0, nactive_vars );
cvSet( &submask1, cvScalar(1) );
if( nactive_vars < var_count )
{
CvMat submask2;
cvGetCols( active_var_mask, &submask2, nactive_vars, var_count );
cvZero( &submask2 );
}
if( nactive_vars < var_count )
{
CvMat submask2;
cvGetCols( active_var_mask, &submask2, nactive_vars, var_count );
cvZero( &submask2 );
}
}
}

View File

@ -1065,10 +1065,10 @@ bool CvSVMSolver::solve_eps_svr( int _sample_count, int _var_count, const float*
CvSVMKernel* _kernel, double* _alpha, CvSVMSolutionInfo& _si )
{
int i;
double p = _kernel->params->p, C = _kernel->params->C;
double p = _kernel->params->p, _C = _kernel->params->C;
if( !create( _sample_count, _var_count, _samples, 0,
_sample_count*2, 0, C, C, _storage, _kernel, &CvSVMSolver::get_row_svr,
_sample_count*2, 0, _C, _C, _storage, _kernel, &CvSVMSolver::get_row_svr,
&CvSVMSolver::select_working_set, &CvSVMSolver::calc_rho ))
return false;
@ -1101,7 +1101,7 @@ bool CvSVMSolver::solve_nu_svr( int _sample_count, int _var_count, const float**
CvSVMKernel* _kernel, double* _alpha, CvSVMSolutionInfo& _si )
{
int i;
double C = _kernel->params->C, sum;
double _C = _kernel->params->C, sum;
if( !create( _sample_count, _var_count, _samples, 0,
_sample_count*2, 0, 1., 1., _storage, _kernel, &CvSVMSolver::get_row_svr,
@ -1110,11 +1110,11 @@ bool CvSVMSolver::solve_nu_svr( int _sample_count, int _var_count, const float**
y = (schar*)cvMemStorageAlloc( storage, sample_count*2*sizeof(y[0]) );
alpha = (double*)cvMemStorageAlloc( storage, alpha_count*sizeof(alpha[0]) );
sum = C * _kernel->params->nu * sample_count * 0.5;
sum = _C * _kernel->params->nu * sample_count * 0.5;
for( i = 0; i < sample_count; i++ )
{
alpha[i] = alpha[i + sample_count] = MIN(sum, C);
alpha[i] = alpha[i + sample_count] = MIN(sum, _C);
sum -= alpha[i];
b[i] = -_y[i];
@ -1628,12 +1628,11 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
int svm_type, sample_count, var_count, sample_size;
int block_size = 1 << 16;
double* alpha;
int i, k;
RNG* rng = &theRNG();
// all steps are logarithmic and must be > 1
double degree_step = 10, g_step = 10, coef_step = 10, C_step = 10, nu_step = 10, p_step = 10;
double gamma = 0, C = 0, degree = 0, coef = 0, p = 0, nu = 0;
double gamma = 0, _C = 0, degree = 0, coef = 0, p = 0, nu = 0;
double best_degree = 0, best_gamma = 0, best_coef = 0, best_C = 0, best_nu = 0, best_p = 0;
float min_error = FLT_MAX, error;
@ -1760,7 +1759,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
cvZero( responses_local );
// randomly permute samples and responses
for( i = 0; i < sample_count; i++ )
for(int i = 0; i < sample_count; i++ )
{
int i1 = (*rng)(sample_count);
int i2 = (*rng)(sample_count);
@ -1779,7 +1778,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
{
// count class samples
int num_0=0,num_1=0;
for (i=0; i<sample_count; ++i)
for (int i=0; i<sample_count; ++i)
{
if (responses->data.i[i]==class_labels->data.i[0])
++num_0;
@ -1875,10 +1874,10 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
}
int* cls_lbls = class_labels ? class_labels->data.i : 0;
C = C_grid.min_val;
_C = C_grid.min_val;
do
{
params.C = C;
params.C = _C;
gamma = gamma_grid.min_val;
do
{
@ -1906,7 +1905,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
int train_size = trainset_size;
error = 0;
for( k = 0; k < k_fold; k++ )
for(int k = 0; k < k_fold; k++ )
{
memcpy( samples_local, samples, sizeof(samples[0])*test_size*k );
memcpy( samples_local + test_size*k, test_samples_ptr + test_size,
@ -1930,7 +1929,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
EXIT;
// Compute test set error on <test_size> samples
for( i = 0; i < test_size; i++, true_resp += resp_elem_size, test_samples_ptr++ )
for(int i = 0; i < test_size; i++, true_resp += resp_elem_size, test_samples_ptr++ )
{
float resp = predict( *test_samples_ptr, var_count );
error += is_regression ? powf( resp - *(float*)true_resp, 2 )
@ -1943,7 +1942,7 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
best_degree = degree;
best_gamma = gamma;
best_coef = coef;
best_C = C;
best_C = _C;
best_nu = nu;
best_p = p;
}
@ -1962,9 +1961,9 @@ bool CvSVM::train_auto( const CvMat* _train_data, const CvMat* _responses,
gamma *= gamma_grid.step;
}
while( gamma < gamma_grid.max_val );
C *= C_grid.step;
_C *= C_grid.step;
}
while( C < C_grid.max_val );
while( _C < C_grid.max_val );
}
min_error /= (float) sample_count;

View File

@ -564,15 +564,15 @@ void CvDTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
if( cv_n )
{
unsigned short* udst = 0;
int* idst = 0;
unsigned short* usdst = 0;
int* idst2 = 0;
if (is_buf_16u)
{
udst = (unsigned short*)(buf->data.s + (get_work_var_count()-1)*sample_count);
usdst = (unsigned short*)(buf->data.s + (get_work_var_count()-1)*sample_count);
for( i = vi = 0; i < sample_count; i++ )
{
udst[i] = (unsigned short)vi++;
usdst[i] = (unsigned short)vi++;
vi &= vi < cv_n ? -1 : 0;
}
@ -581,15 +581,15 @@ void CvDTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
int a = (*rng)(sample_count);
int b = (*rng)(sample_count);
unsigned short unsh = (unsigned short)vi;
CV_SWAP( udst[a], udst[b], unsh );
CV_SWAP( usdst[a], usdst[b], unsh );
}
}
else
{
idst = buf->data.i + (get_work_var_count()-1)*sample_count;
idst2 = buf->data.i + (get_work_var_count()-1)*sample_count;
for( i = vi = 0; i < sample_count; i++ )
{
idst[i] = vi++;
idst2[i] = vi++;
vi &= vi < cv_n ? -1 : 0;
}
@ -597,7 +597,7 @@ void CvDTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
{
int a = (*rng)(sample_count);
int b = (*rng)(sample_count);
CV_SWAP( idst[a], idst[b], vi );
CV_SWAP( idst2[a], idst2[b], vi );
}
}
}
@ -865,7 +865,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
float* values, uchar* missing,
float* responses, bool get_class_idx )
float* _responses, bool get_class_idx )
{
CvMat* subsample_idx = 0;
CvMat* subsample_co = 0;
@ -962,7 +962,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
}
// copy responses
if( responses )
if( _responses )
{
if( is_classifier )
{
@ -972,7 +972,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
int idx = sidx ? sidx[i] : i;
int val = get_class_idx ? src[idx] :
cat_map->data.i[cat_ofs->data.i[cat_var_count]+src[idx]];
responses[i] = (float)val;
_responses[i] = (float)val;
}
}
else
@ -983,7 +983,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
for( i = 0; i < count; i++ )
{
int idx = sidx ? sidx[i] : i;
responses[i] = _values[idx];
_responses[i] = _values[idx];
}
}
}
@ -1205,11 +1205,11 @@ const int* CvDTreeTrainData::get_sample_indices( CvDTreeNode* n, int* indices_bu
const float* CvDTreeTrainData::get_ord_responses( CvDTreeNode* n, float* values_buf, int*sample_indices_buf )
{
int sample_count = n->sample_count;
int _sample_count = n->sample_count;
int r_step = CV_IS_MAT_CONT(responses->type) ? 1 : responses->step/CV_ELEM_SIZE(responses->type);
const int* indices = get_sample_indices(n, sample_indices_buf);
for( int i = 0; i < sample_count &&
for( int i = 0; i < _sample_count &&
(((indices[i] >= 0) && !is_buf_16u) || ((indices[i] != 65535) && is_buf_16u)); i++ )
{
int idx = indices[i];
@ -3527,7 +3527,7 @@ int CvDTree::cut_tree( int T, int fold, double min_alpha )
}
void CvDTree::free_prune_data(bool cut_tree)
void CvDTree::free_prune_data(bool _cut_tree)
{
CvDTreeNode* node = root;
@ -3548,7 +3548,7 @@ void CvDTree::free_prune_data(bool cut_tree)
for( parent = node->parent; parent && parent->right == node;
node = parent, parent = parent->parent )
{
if( cut_tree && parent->Tn <= pruned_tree_idx )
if( _cut_tree && parent->Tn <= pruned_tree_idx )
{
data->free_node( parent->left );
data->free_node( parent->right );

Some files were not shown because too many files have changed in this diff Show More