mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #1567 from ilya-lavrenov:warn_fix
This commit is contained in:
@@ -112,7 +112,7 @@ static Mat _localAffineEstimate(const std::vector<Point2f>& shape1, const std::v
|
||||
bool fullAfine)
|
||||
{
|
||||
Mat out(2,3,CV_32F);
|
||||
int siz=2*shape1.size();
|
||||
int siz=2*(int)shape1.size();
|
||||
|
||||
if (fullAfine)
|
||||
{
|
||||
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
comparer=_comparer;
|
||||
iterations=_iterations;
|
||||
transformer=_transformer;
|
||||
bendingEnergyWeight=0.3;
|
||||
imageAppearanceWeight=0.0;
|
||||
shapeContextWeight=1.0;
|
||||
sigma=10;
|
||||
bendingEnergyWeight=0.3f;
|
||||
imageAppearanceWeight=0.0f;
|
||||
shapeContextWeight=1.0f;
|
||||
sigma=10.0f;
|
||||
name_ = "ShapeDistanceExtractor.SCD";
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ void SCDMatcher::hungarian(cv::Mat &costMatrix, std::vector<cv::DMatch> &outMatc
|
||||
std::vector<int> matches(costMatrix.rows, 0), colsol(costMatrix.rows), rowsol(costMatrix.rows);
|
||||
std::vector<float> d(costMatrix.rows), pred(costMatrix.rows), v(costMatrix.rows);
|
||||
|
||||
const float LOWV=1e-10;
|
||||
const float LOWV = 1e-10f;
|
||||
bool unassignedfound;
|
||||
int i=0, imin=0, numfree=0, prvnumfree=0, f=0, i0=0, k=0, freerow=0;
|
||||
int j=0, j1=0, j2=0, endofpath=0, last=0, low=0, up=0;
|
||||
|
||||
@@ -212,9 +212,9 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts
|
||||
}
|
||||
|
||||
// Organizing the correspondent points in matrix style //
|
||||
Mat shape1(matches.size(),2,CV_32F); // transforming shape
|
||||
Mat shape2(matches.size(),2,CV_32F); // target shape
|
||||
for (size_t i=0; i<matches.size(); i++)
|
||||
Mat shape1((int)matches.size(),2,CV_32F); // transforming shape
|
||||
Mat shape2((int)matches.size(),2,CV_32F); // target shape
|
||||
for (int i=0, end = (int)matches.size(); i<end; i++)
|
||||
{
|
||||
Point2f pt1=pts1.at<Point2f>(0,matches[i].queryIdx);
|
||||
shape1.at<float>(i,0) = pt1.x;
|
||||
@@ -229,11 +229,11 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts
|
||||
// Building the matrices for solving the L*(w|a)=(v|0) problem with L={[K|P];[P'|0]}
|
||||
|
||||
//Building K and P (Neede to buil L)
|
||||
Mat matK(matches.size(),matches.size(),CV_32F);
|
||||
Mat matP(matches.size(),3,CV_32F);
|
||||
for (size_t i=0; i<matches.size(); i++)
|
||||
Mat matK((int)matches.size(),(int)matches.size(),CV_32F);
|
||||
Mat matP((int)matches.size(),3,CV_32F);
|
||||
for (int i=0, end=(int)matches.size(); i<end; i++)
|
||||
{
|
||||
for (size_t j=0; j<matches.size(); j++)
|
||||
for (int j=0; j<end; j++)
|
||||
{
|
||||
if (i==j)
|
||||
{
|
||||
@@ -251,19 +251,19 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts
|
||||
}
|
||||
|
||||
//Building L
|
||||
Mat matL=Mat::zeros(matches.size()+3,matches.size()+3,CV_32F);
|
||||
Mat matLroi(matL, Rect(0,0,matches.size(),matches.size())); //roi for K
|
||||
Mat matL=Mat::zeros((int)matches.size()+3,(int)matches.size()+3,CV_32F);
|
||||
Mat matLroi(matL, Rect(0,0,(int)matches.size(),(int)matches.size())); //roi for K
|
||||
matK.copyTo(matLroi);
|
||||
matLroi = Mat(matL,Rect(matches.size(),0,3,matches.size())); //roi for P
|
||||
matLroi = Mat(matL,Rect((int)matches.size(),0,3,(int)matches.size())); //roi for P
|
||||
matP.copyTo(matLroi);
|
||||
Mat matPt;
|
||||
transpose(matP,matPt);
|
||||
matLroi = Mat(matL,Rect(0,matches.size(),matches.size(),3)); //roi for P'
|
||||
matLroi = Mat(matL,Rect(0,(int)matches.size(),(int)matches.size(),3)); //roi for P'
|
||||
matPt.copyTo(matLroi);
|
||||
|
||||
//Building B (v|0)
|
||||
Mat matB = Mat::zeros(matches.size()+3,2,CV_32F);
|
||||
for (size_t i=0; i<matches.size(); i++)
|
||||
Mat matB = Mat::zeros((int)matches.size()+3,2,CV_32F);
|
||||
for (int i=0, end = (int)matches.size(); i<end; i++)
|
||||
{
|
||||
matB.at<float>(i,0) = shape2.at<float>(i,0); //x's
|
||||
matB.at<float>(i,1) = shape2.at<float>(i,1); //y's
|
||||
|
||||
@@ -46,11 +46,11 @@ using namespace std;
|
||||
|
||||
const int angularBins=12;
|
||||
const int radialBins=4;
|
||||
const float minRad=0.2;
|
||||
const float minRad=0.2f;
|
||||
const float maxRad=2;
|
||||
const int NSN=5;//10;//20; //number of shapes per class
|
||||
const int NP=100; //number of points sympliying the contour
|
||||
const float outlierWeight=0.1;
|
||||
const float outlierWeight=0.1f;
|
||||
const int numOutliers=20;
|
||||
const float CURRENT_MAX_ACCUR=95; //98% and 99% reached in several tests, 95 is fixed as minimum boundary
|
||||
|
||||
@@ -96,7 +96,7 @@ vector <Point2f> CV_ShapeEMDTest::convertContourType(const Mat& currentQuery, in
|
||||
|
||||
// In case actual number of points is less than n
|
||||
int dum=0;
|
||||
for (int add=contoursQuery.size()-1; add<n; add++)
|
||||
for (int add=(int)contoursQuery.size()-1; add<n; add++)
|
||||
{
|
||||
contoursQuery.push_back(contoursQuery[dum++]); //adding dummy values
|
||||
}
|
||||
@@ -148,14 +148,14 @@ void CV_ShapeEMDTest::mpegTest()
|
||||
listShapeNames(namesHeaders);
|
||||
|
||||
// distance matrix //
|
||||
Mat distanceMat=Mat::zeros(NSN*namesHeaders.size(), NSN*namesHeaders.size(), CV_32F);
|
||||
Mat distanceMat=Mat::zeros(NSN*(int)namesHeaders.size(), NSN*(int)namesHeaders.size(), CV_32F);
|
||||
|
||||
// query contours (normal v flipped, h flipped) and testing contour //
|
||||
vector<Point2f> contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting;
|
||||
|
||||
// reading query and computing its properties //
|
||||
int counter=0;
|
||||
const int loops=NSN*namesHeaders.size()*NSN*namesHeaders.size();
|
||||
const int loops=NSN*(int)namesHeaders.size()*NSN*(int)namesHeaders.size();
|
||||
for (size_t n=0; n<namesHeaders.size(); n++)
|
||||
{
|
||||
for (int i=1; i<=NSN; i++)
|
||||
@@ -165,7 +165,6 @@ void CV_ShapeEMDTest::mpegTest()
|
||||
thepathandname<<path+namesHeaders[n]<<"-"<<i<<".png";
|
||||
Mat currentQuery, flippedHQuery, flippedVQuery;
|
||||
currentQuery=imread(thepathandname.str(), IMREAD_GRAYSCALE);
|
||||
Mat currentQueryBuf=currentQuery.clone();
|
||||
flip(currentQuery, flippedHQuery, 0);
|
||||
flip(currentQuery, flippedVQuery, 1);
|
||||
// compute border of the query and its flipped versions //
|
||||
@@ -184,8 +183,8 @@ void CV_ShapeEMDTest::mpegTest()
|
||||
counter++;
|
||||
if (nt==n && it==i)
|
||||
{
|
||||
distanceMat.at<float>(NSN*n+i-1,
|
||||
NSN*nt+it-1)=0;
|
||||
distanceMat.at<float>(NSN*(int)n+i-1,
|
||||
NSN*(int)nt+it-1)=0;
|
||||
continue;
|
||||
}
|
||||
// read testing image //
|
||||
@@ -200,9 +199,9 @@ void CV_ShapeEMDTest::mpegTest()
|
||||
std::cout<<std::endl<<"Progress: "<<counter<<"/"<<loops<<": "<<100*double(counter)/loops<<"% *******"<<std::endl;
|
||||
std::cout<<"Computing shape distance between "<<namesHeaders[n]<<i<<
|
||||
" and "<<namesHeaders[nt]<<it<<": ";
|
||||
distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)=
|
||||
distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)=
|
||||
computeShapeDistance(contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting);
|
||||
std::cout<<distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)<<std::endl;
|
||||
std::cout<<distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ CV_HaussTest::~CV_HaussTest()
|
||||
vector<Point2f> CV_HaussTest::normalizeContour(const vector<Point> &contour)
|
||||
{
|
||||
vector<Point2f> output(contour.size());
|
||||
Mat disMat(contour.size(),contour.size(),CV_32F);
|
||||
Mat disMat((int)contour.size(),(int)contour.size(),CV_32F);
|
||||
Point2f meanpt(0,0);
|
||||
float meanVal=1;
|
||||
|
||||
for (size_t ii=0; ii<contour.size(); ii++)
|
||||
for (int ii=0, end1 = (int)contour.size(); ii<end1; ii++)
|
||||
{
|
||||
for (size_t jj=0; jj<contour.size(); jj++)
|
||||
for (int jj=0, end2 = (int)contour.size(); end2; jj++)
|
||||
{
|
||||
if (ii==jj) disMat.at<float>(ii,jj)=0;
|
||||
else
|
||||
@@ -128,7 +128,7 @@ vector <Point> CV_HaussTest::convertContourType(const Mat& currentQuery, int n)
|
||||
}
|
||||
|
||||
// In case actual number of points is less than n
|
||||
for (int add=contoursQuery.size()-1; add<n; add++)
|
||||
for (int add=(int)contoursQuery.size()-1; add<n; add++)
|
||||
{
|
||||
contoursQuery.push_back(contoursQuery[contoursQuery.size()-add+1]); //adding dummy values
|
||||
}
|
||||
@@ -160,14 +160,14 @@ void CV_HaussTest::mpegTest()
|
||||
listShapeNames(namesHeaders);
|
||||
|
||||
// distance matrix //
|
||||
Mat distanceMat=Mat::zeros(NSN*namesHeaders.size(), NSN*namesHeaders.size(), CV_32F);
|
||||
Mat distanceMat=Mat::zeros(NSN*(int)namesHeaders.size(), NSN*(int)namesHeaders.size(), CV_32F);
|
||||
|
||||
// query contours (normal v flipped, h flipped) and testing contour //
|
||||
vector<Point> contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting;
|
||||
|
||||
// reading query and computing its properties //
|
||||
int counter=0;
|
||||
const int loops=NSN*namesHeaders.size()*NSN*namesHeaders.size();
|
||||
const int loops=NSN*(int)namesHeaders.size()*NSN*(int)namesHeaders.size();
|
||||
for (size_t n=0; n<namesHeaders.size(); n++)
|
||||
{
|
||||
for (int i=1; i<=NSN; i++)
|
||||
@@ -195,8 +195,8 @@ void CV_HaussTest::mpegTest()
|
||||
counter++;
|
||||
if (nt==n && it==i)
|
||||
{
|
||||
distanceMat.at<float>(NSN*n+i-1,
|
||||
NSN*nt+it-1)=0;
|
||||
distanceMat.at<float>(NSN*(int)n+i-1,
|
||||
NSN*(int)nt+it-1)=0;
|
||||
continue;
|
||||
}
|
||||
// read testing image //
|
||||
@@ -212,9 +212,9 @@ void CV_HaussTest::mpegTest()
|
||||
std::cout<<std::endl<<"Progress: "<<counter<<"/"<<loops<<": "<<100*double(counter)/loops<<"% *******"<<std::endl;
|
||||
std::cout<<"Computing shape distance between "<<namesHeaders[n]<<i<<
|
||||
" and "<<namesHeaders[nt]<<it<<": ";
|
||||
distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)=
|
||||
distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)=
|
||||
computeShapeDistance(contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting);
|
||||
std::cout<<distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)<<std::endl;
|
||||
std::cout<<distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ using namespace std;
|
||||
|
||||
const int angularBins=12;
|
||||
const int radialBins=4;
|
||||
const float minRad=0.2;
|
||||
const float minRad=0.2f;
|
||||
const float maxRad=2;
|
||||
const int NSN=5;//10;//20; //number of shapes per class
|
||||
const int NP=120; //number of points sympliying the contour
|
||||
const float outlierWeight=0.1;
|
||||
const float outlierWeight=0.1f;
|
||||
const int numOutliers=20;
|
||||
const float CURRENT_MAX_ACCUR=95.0; //99% and 100% reached in several tests, 95 is fixed as minimum boundary
|
||||
const float CURRENT_MAX_ACCUR=95; //99% and 100% reached in several tests, 95 is fixed as minimum boundary
|
||||
|
||||
class CV_ShapeTest : public cvtest::BaseTest
|
||||
{
|
||||
@@ -95,7 +95,7 @@ vector <Point2f> CV_ShapeTest::convertContourType(const Mat& currentQuery, int n
|
||||
}
|
||||
|
||||
// In case actual number of points is less than n
|
||||
for (int add=contoursQuery.size()-1; add<n; add++)
|
||||
for (int add=(int)contoursQuery.size()-1; add<n; add++)
|
||||
{
|
||||
contoursQuery.push_back(contoursQuery[contoursQuery.size()-add+1]); //adding dummy values
|
||||
}
|
||||
@@ -126,7 +126,7 @@ float CV_ShapeTest::computeShapeDistance(vector <Point2f>& query1, vector <Point
|
||||
//waitKey(0);
|
||||
Ptr <ShapeContextDistanceExtractor> mysc = createShapeContextDistanceExtractor(angularBins, radialBins, minRad, maxRad);
|
||||
//Ptr <HistogramCostExtractor> cost = createNormHistogramCostExtractor(cv::DIST_L1);
|
||||
Ptr <HistogramCostExtractor> cost = createChiHistogramCostExtractor(30,0.15);
|
||||
Ptr <HistogramCostExtractor> cost = createChiHistogramCostExtractor(30,0.15f);
|
||||
//Ptr <HistogramCostExtractor> cost = createEMDHistogramCostExtractor();
|
||||
//Ptr <HistogramCostExtractor> cost = createEMDL1HistogramCostExtractor();
|
||||
mysc->setIterations(1);
|
||||
@@ -148,14 +148,14 @@ void CV_ShapeTest::mpegTest()
|
||||
listShapeNames(namesHeaders);
|
||||
|
||||
// distance matrix //
|
||||
Mat distanceMat=Mat::zeros(NSN*namesHeaders.size(), NSN*namesHeaders.size(), CV_32F);
|
||||
Mat distanceMat=Mat::zeros(NSN*(int)namesHeaders.size(), NSN*(int)namesHeaders.size(), CV_32F);
|
||||
|
||||
// query contours (normal v flipped, h flipped) and testing contour //
|
||||
vector<Point2f> contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting;
|
||||
|
||||
// reading query and computing its properties //
|
||||
int counter=0;
|
||||
const int loops=NSN*namesHeaders.size()*NSN*namesHeaders.size();
|
||||
const int loops=NSN*(int)namesHeaders.size()*NSN*(int)namesHeaders.size();
|
||||
for (size_t n=0; n<namesHeaders.size(); n++)
|
||||
{
|
||||
for (int i=1; i<=NSN; i++)
|
||||
@@ -184,8 +184,8 @@ void CV_ShapeTest::mpegTest()
|
||||
counter++;
|
||||
if (nt==n && it==i)
|
||||
{
|
||||
distanceMat.at<float>(NSN*n+i-1,
|
||||
NSN*nt+it-1)=0;
|
||||
distanceMat.at<float>(NSN*(int)n+i-1,
|
||||
NSN*(int)nt+it-1)=0;
|
||||
continue;
|
||||
}
|
||||
// read testing image //
|
||||
@@ -200,9 +200,9 @@ void CV_ShapeTest::mpegTest()
|
||||
std::cout<<std::endl<<"Progress: "<<counter<<"/"<<loops<<": "<<100*double(counter)/loops<<"% *******"<<std::endl;
|
||||
std::cout<<"Computing shape distance between "<<namesHeaders[n]<<i<<
|
||||
" and "<<namesHeaders[nt]<<it<<": ";
|
||||
distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)=
|
||||
distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)=
|
||||
computeShapeDistance(contoursQuery1, contoursQuery2, contoursQuery3, contoursTesting);
|
||||
std::cout<<distanceMat.at<float>(NSN*n+i-1, NSN*nt+it-1)<<std::endl;
|
||||
std::cout<<distanceMat.at<float>(NSN*(int)n+i-1, NSN*(int)nt+it-1)<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user