diff --git a/modules/shape/doc/histogram_cost_matrix.rst b/modules/shape/doc/histogram_cost_matrix.rst index 9f6804dd0b..8c338dbee7 100644 --- a/modules/shape/doc/histogram_cost_matrix.rst +++ b/modules/shape/doc/histogram_cost_matrix.rst @@ -70,7 +70,7 @@ An Chi based cost extraction. :: CV_EXPORTS_W Ptr createChiHistogramCostExtractor(int nDummies=25, float defaultCost=0.2); EMDL1HistogramCostExtractor -------------------------- +--------------------------- .. ocv:class:: EMDL1HistogramCostExtractor : public HistogramCostExtractor An EMD-L1 based cost extraction. :: diff --git a/modules/shape/doc/shape_distances.rst b/modules/shape/doc/shape_distances.rst index c671e97ed5..6a6ce95329 100644 --- a/modules/shape/doc/shape_distances.rst +++ b/modules/shape/doc/shape_distances.rst @@ -1,11 +1,11 @@ -Shape Distance and Common Interfaces +Shape Distance and Common Interfaces ==================================== .. highlight:: cpp Shape Distance algorithms in OpenCV are derivated from a common interface that allows you to switch between them in a practical way for solving the same problem with different methods. -Thus, all objects that implement shape distance measures inherit the +Thus, all objects that implement shape distance measures inherit the :ocv:class:`ShapeDistanceExtractor` interface. @@ -123,7 +123,7 @@ ShapeContextDistanceExtractor::setShapeContextWeight ---------------------------------------------------- Set the weight of the shape context distance in the final value of the shape distance. The shape context distance between two shapes is defined as the symmetric sum of shape -context matching costs over best matching points. +context matching costs over best matching points. The final value of the shape distance is a user-defined linear combination of the shape context distance, an image appearance distance, and a bending energy. diff --git a/modules/shape/include/opencv2/shape/emdL1.hpp b/modules/shape/include/opencv2/shape/emdL1.hpp index 400d26b261..74c734a519 100644 --- a/modules/shape/include/opencv2/shape/emdL1.hpp +++ b/modules/shape/include/opencv2/shape/emdL1.hpp @@ -55,4 +55,4 @@ CV_EXPORTS float EMDL1(InputArray signature1, InputArray signature2); }//namespace cv -#endif +#endif diff --git a/modules/shape/src/aff_trans.cpp b/modules/shape/src/aff_trans.cpp index c416b82056..e3d41d0ea4 100644 --- a/modules/shape/src/aff_trans.cpp +++ b/modules/shape/src/aff_trans.cpp @@ -88,7 +88,7 @@ public: virtual void read(const FileNode& fn) { CV_Assert( (String)fn["name"] == name_ ); - fullAffine = (int)fn["affine_type"]; + fullAffine = (bool)int(fn["affine_type"]); } private: diff --git a/modules/shape/src/emdL1.cpp b/modules/shape/src/emdL1.cpp index cdd903e1ab..423f8ef5d6 100644 --- a/modules/shape/src/emdL1.cpp +++ b/modules/shape/src/emdL1.cpp @@ -41,11 +41,11 @@ //M*/ /* - * Implementation of an optimized EMD for histograms based in - * the papers "EMD-L1: An efficient and Robust Algorithm - * for comparing histogram-based descriptors", by Haibin Ling and + * Implementation of an optimized EMD for histograms based in + * the papers "EMD-L1: An efficient and Robust Algorithm + * for comparing histogram-based descriptors", by Haibin Ling and * Kazunori Okuda; and "The Earth Mover's Distance is the Mallows - * Distance: Some Insights from Statistics", by Elizaveta Levina and + * Distance: Some Insights from Statistics", by Elizaveta Levina and * Peter Bickel, based on HAIBIN LING AND KAZUNORI OKADA implementation. */ @@ -393,9 +393,9 @@ bool EmdL1::greedySolution3() //- determine which direction to move, either right or upward dFlow = D[i1][i2][i3]; - f1 = i1<(binsDim1-1)?fabs(dFlow+d1s[i1+1]):VHIGH; - f2 = i2<(binsDim2-1)?fabs(dFlow+d2s[i2+1]):VHIGH; - f3 = i3<(binsDim3-1)?fabs(dFlow+d3s[i3+1]):VHIGH; + f1 = i1<(binsDim1-1)?(float)fabs(dFlow+d1s[i1+1]):VHIGH; + f2 = i2<(binsDim2-1)?(float)fabs(dFlow+d2s[i2+1]):VHIGH; + f3 = i3<(binsDim3-1)?(float)fabs(dFlow+d3s[i3+1]):VHIGH; if(f1(0,r)-set2.at(0,c); - disMat.at(r,c) = norm(Mat(diff), distType); + disMat.at(r,c) = (float)norm(Mat(diff), distType); } } @@ -147,5 +147,3 @@ Ptr createHausdorffDistanceExtractor(int distanceFl } } // cv - - diff --git a/modules/shape/src/hist_cost.cpp b/modules/shape/src/hist_cost.cpp index 67e4063e6b..4e18687ad8 100644 --- a/modules/shape/src/hist_cost.cpp +++ b/modules/shape/src/hist_cost.cpp @@ -156,7 +156,7 @@ void NormHistogramCostExtractorImpl::buildCostMatrix(InputArray _descriptors1, I if (i(i,j)=norm(columnDiff, flag); + costMatrix.at(i,j)=(float)norm(columnDiff, flag); } else { @@ -288,11 +288,11 @@ void EMDHistogramCostExtractorImpl::buildCostMatrix(InputArray _descriptors1, In sig2.col(0)=scd2.row(j).t(); for (int k=0; k(k,1)=k; + sig1.at(k,1)=float(k); } for (int k=0; k(k,1)=k; + sig2.at(k,1)=float(k); } costMatrix.at(i,j) = cv::EMD(sig1, sig2, flag); @@ -543,5 +543,3 @@ Ptr createEMDL1HistogramCostExtractor(int nDummies, flo } } // cv - - diff --git a/modules/shape/src/sc_dis.cpp b/modules/shape/src/sc_dis.cpp index 98edc56b1f..e41efc2298 100644 --- a/modules/shape/src/sc_dis.cpp +++ b/modules/shape/src/sc_dis.cpp @@ -42,7 +42,7 @@ /* * Implementation of the paper Shape Matching and Object Recognition Using Shape Contexts - * Belongie et al., 2002 by Juan Manuel Perez for GSoC 2013. + * Belongie et al., 2002 by Juan Manuel Perez for GSoC 2013. */ #include "precomp.hpp" //#include "opencv2/highgui.hpp" @@ -176,7 +176,7 @@ protected: { for (int j=0; j(i,j) = norm( cv::Mat(contourMat.at(0,i)-contourMat.at(0,j)), cv::NORM_L2 ); + disMatrix.at(i,j) = (float)norm( cv::Mat(contourMat.at(0,i)-contourMat.at(0,j)), cv::NORM_L2 ); if (_meanDistance<0) { if (queryInliers.size()>0) @@ -193,7 +193,7 @@ protected: if (_meanDistance<0) { - meanDistance=mean(disMatrix, mask)[0]; + meanDistance=(float)mean(disMatrix, mask)[0]; } else { @@ -239,7 +239,7 @@ protected: float refAngle = atan2(refPt.y, refPt.x); angleMatrix.at(i,j) -= refAngle; } - angleMatrix.at(i,j) = fmod(angleMatrix.at(i,j)+FLT_EPSILON,2*CV_PI)+CV_PI; + angleMatrix.at(i,j) = float(fmod(double(angleMatrix.at(i,j)+(double)FLT_EPSILON),2*CV_PI)+CV_PI); //angleMatrix.at(i,j) = 1+floor( angleMatrix.at(i,j)*nAngularBins/(2*CV_PI) ); } } @@ -426,7 +426,7 @@ protected: for (j = 0; j < costMatrix.rows; j++) { d[j] = costMatrix.at(freerow,j) - v[j]; - pred[j] = freerow; + pred[j] = float(freerow); collist[j] = j; // init column list. } @@ -479,7 +479,7 @@ protected: v2 = costMatrix.at(i,j) - v[j] - h; if (v2 < d[j]) { - pred[j] = i; + pred[j] = float(i); if (v2 == min) { if (colsol[j] < 0) @@ -511,7 +511,7 @@ protected: // reset row and column assignments along the alternating path. do { - i = pred[endofpath]; + i = int(pred[endofpath]); colsol[endofpath] = i; j1 = endofpath; endofpath = rowsol[i]; @@ -526,7 +526,7 @@ protected: { double minval; minMaxIdx(trueCostMatrix.row(nrow), &minval); - leftcost+=minval; + leftcost+=float(minval); } leftcost /= trueCostMatrix.rows; @@ -535,7 +535,7 @@ protected: { double minval; minMaxIdx(trueCostMatrix.col(ncol), &minval); - rightcost+=minval; + rightcost+=float(minval); } rightcost /= trueCostMatrix.cols; @@ -815,7 +815,7 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In { float xx = sset1.at(0,pt).x; float yy = sset1.at(0,pt).y; - float val = std::exp( -( (xx-jj)*(xx-jj) + (yy-ii)*(yy-ii) )/(2*sigma*sigma) ) / (sigma*sigma*2*CV_PI); + float val = float(std::exp( -float( (xx-jj)*(xx-jj) + (yy-ii)*(yy-ii) )/(2*sigma*sigma) ) / (sigma*sigma*2*CV_PI)); gaussWindow.at(ii,jj) += val; } } @@ -831,7 +831,7 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In appIm.at(ii,jj) = elema*elemb; } } - iAppearance = cv::sum(appIm)[0]/sset1.cols; + iAppearance = float(cv::sum(appIm)[0]/sset1.cols); } sDistance = matcher.getMatchingCost(); diff --git a/modules/shape/src/tps_trans.cpp b/modules/shape/src/tps_trans.cpp index dd839d670c..b841567dca 100644 --- a/modules/shape/src/tps_trans.cpp +++ b/modules/shape/src/tps_trans.cpp @@ -104,7 +104,7 @@ protected: String name_; }; -static double distance(Point2f p, Point2f q) +static float distance(Point2f p, Point2f q) { Point2f diff = p - q; float norma = diff.x*diff.x + diff.y*diff.y;// - 2*diff.x*diff.y; @@ -237,7 +237,7 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts { if (i==j) { - matK.at(i,j)=regularizationParameter; + matK.at(i,j)=float(regularizationParameter); } else { diff --git a/modules/shape/test/test_hausdorff.cpp b/modules/shape/test/test_hausdorff.cpp index dfff6bcb3c..d1fdf3881a 100644 --- a/modules/shape/test/test_hausdorff.cpp +++ b/modules/shape/test/test_hausdorff.cpp @@ -87,7 +87,7 @@ vector CV_HaussTest::normalizeContour(const vector &contour) else { disMat.at(ii,jj)= - fabs(contour[ii].x*contour[jj].x)+fabs(contour[ii].y*contour[jj].y); + float(fabs(double(contour[ii].x*contour[jj].x)))+float(fabs(double(contour[ii].y*contour[jj].y))); } } meanpt.x+=contour[ii].x; @@ -95,7 +95,7 @@ vector CV_HaussTest::normalizeContour(const vector &contour) } meanpt.x/=contour.size(); meanpt.y/=contour.size(); - meanVal=cv::mean(disMat)[0]; + meanVal=float(cv::mean(disMat)[0]); for (size_t ii=0; iiset_failed_test_info(cvtest::TS::OK); + ts->set_failed_test_info(cvtest::TS::OK); } TEST(Hauss, regression) { CV_HaussTest test; test.safe_run(); } diff --git a/modules/shape/test/test_shape.cpp b/modules/shape/test/test_shape.cpp index 81d67f6ac1..6415420072 100644 --- a/modules/shape/test/test_shape.cpp +++ b/modules/shape/test/test_shape.cpp @@ -81,7 +81,7 @@ CV_ShapeTest::~CV_ShapeTest() } vector CV_ShapeTest::convertContourType(const Mat& currentQuery, int n) -{ +{ vector > _contoursQuery; vector contoursQuery; findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE); diff --git a/samples/cpp/shape_example.cpp b/samples/cpp/shape_example.cpp index 921330e894..d723a73e5f 100644 --- a/samples/cpp/shape_example.cpp +++ b/samples/cpp/shape_example.cpp @@ -75,7 +75,7 @@ int main(int argc, char** argv) imshow("QUERY", queryToShow); moveWindow("TEST", 0,0); vector contQuery = simpleContour(query); - int bestMatch; + int bestMatch = 0; float bestDis=FLT_MAX; for ( int ii=1; ii<=20; ii++ ) { diff --git a/samples/cpp/shape_transformation.cpp b/samples/cpp/shape_transformation.cpp index aa83cd7d14..abd7eab7b1 100644 --- a/samples/cpp/shape_transformation.cpp +++ b/samples/cpp/shape_transformation.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv) BFMatcher matcher(NORM_L2); vector matches; matcher.match(descriptors1, descriptors2, matches); - + // drawing the results namedWindow("matches", 1); Mat img_matches;