CV_EXPORTS_W Ptr<HistogramCostExtractor> createChiHistogramCostExtractor(int nDummies=25, float defaultCost=0.2);
EMDL1HistogramCostExtractor
--------------------------
+---------------------------
.. ocv:class:: EMDL1HistogramCostExtractor : public HistogramCostExtractor
An EMD-L1 based cost extraction. ::
-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.
----------------------------------------------------
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.
}//namespace cv
-#endif
+#endif
virtual void read(const FileNode& fn)
{
CV_Assert( (String)fn["name"] == name_ );
- fullAffine = (int)fn["affine_type"];
+ fullAffine = (bool)int(fn["affine_type"]);
}
private:
//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.
*/
//- 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<f2 && f1<f3)
{
EmdL1 emdl1;
return emdl1.getEMDL1(signature1, signature2);
}
-
int m_iFrom;
int m_iTo;
};
-
{
CV_Assert( (String)fn["name"] == name_ );
distanceFlag = (int)fn["distance"];
- rankProportion = (int)fn["rank"];
+ rankProportion = (float)fn["rank"];
}
private:
for (int c=0; c<disMat.cols; c++)
{
Point2f diff = set1.at<Point2f>(0,r)-set2.at<Point2f>(0,c);
- disMat.at<float>(r,c) = norm(Mat(diff), distType);
+ disMat.at<float>(r,c) = (float)norm(Mat(diff), distType);
}
}
}
} // cv
-
-
if (i<scd1.rows && j<scd2.rows)
{
Mat columnDiff = scd1.row(i)-scd2.row(j);
- costMatrix.at<float>(i,j)=norm(columnDiff, flag);
+ costMatrix.at<float>(i,j)=(float)norm(columnDiff, flag);
}
else
{
sig2.col(0)=scd2.row(j).t();
for (int k=0; k<sig1.rows; k++)
{
- sig1.at<float>(k,1)=k;
+ sig1.at<float>(k,1)=float(k);
}
for (int k=0; k<sig2.rows; k++)
{
- sig2.at<float>(k,1)=k;
+ sig2.at<float>(k,1)=float(k);
}
costMatrix.at<float>(i,j) = cv::EMD(sig1, sig2, flag);
}
} // cv
-
-
/*
* 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"
{
for (int j=0; j<contourMat.cols; j++)
{
- disMatrix.at<float>(i,j) = norm( cv::Mat(contourMat.at<cv::Point2f>(0,i)-contourMat.at<cv::Point2f>(0,j)), cv::NORM_L2 );
+ disMatrix.at<float>(i,j) = (float)norm( cv::Mat(contourMat.at<cv::Point2f>(0,i)-contourMat.at<cv::Point2f>(0,j)), cv::NORM_L2 );
if (_meanDistance<0)
{
if (queryInliers.size()>0)
if (_meanDistance<0)
{
- meanDistance=mean(disMatrix, mask)[0];
+ meanDistance=(float)mean(disMatrix, mask)[0];
}
else
{
float refAngle = atan2(refPt.y, refPt.x);
angleMatrix.at<float>(i,j) -= refAngle;
}
- angleMatrix.at<float>(i,j) = fmod(angleMatrix.at<float>(i,j)+FLT_EPSILON,2*CV_PI)+CV_PI;
+ angleMatrix.at<float>(i,j) = float(fmod(double(angleMatrix.at<float>(i,j)+(double)FLT_EPSILON),2*CV_PI)+CV_PI);
//angleMatrix.at<float>(i,j) = 1+floor( angleMatrix.at<float>(i,j)*nAngularBins/(2*CV_PI) );
}
}
for (j = 0; j < costMatrix.rows; j++)
{
d[j] = costMatrix.at<float>(freerow,j) - v[j];
- pred[j] = freerow;
+ pred[j] = float(freerow);
collist[j] = j; // init column list.
}
v2 = costMatrix.at<float>(i,j) - v[j] - h;
if (v2 < d[j])
{
- pred[j] = i;
+ pred[j] = float(i);
if (v2 == min)
{
if (colsol[j] < 0)
// 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];
{
double minval;
minMaxIdx(trueCostMatrix.row(nrow), &minval);
- leftcost+=minval;
+ leftcost+=float(minval);
}
leftcost /= trueCostMatrix.rows;
{
double minval;
minMaxIdx(trueCostMatrix.col(ncol), &minval);
- rightcost+=minval;
+ rightcost+=float(minval);
}
rightcost /= trueCostMatrix.cols;
{
float xx = sset1.at<Point2f>(0,pt).x;
float yy = sset1.at<Point2f>(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<float>(ii,jj) += val;
}
}
appIm.at<float>(ii,jj) = elema*elemb;
}
}
- iAppearance = cv::sum(appIm)[0]/sset1.cols;
+ iAppearance = float(cv::sum(appIm)[0]/sset1.cols);
}
sDistance = matcher.getMatchingCost();
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;
{
if (i==j)
{
- matK.at<float>(i,j)=regularizationParameter;
+ matK.at<float>(i,j)=float(regularizationParameter);
}
else
{
else
{
disMat.at<float>(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;
}
meanpt.x/=contour.size();
meanpt.y/=contour.size();
- meanVal=cv::mean(disMat)[0];
+ meanVal=float(cv::mean(disMat)[0]);
for (size_t ii=0; ii<contour.size(); ii++)
{
output[ii].x = (contour[ii].x-meanpt.x)/meanVal;
{
mpegTest();
displayMPEGResults();
- ts->set_failed_test_info(cvtest::TS::OK);
+ ts->set_failed_test_info(cvtest::TS::OK);
}
TEST(Hauss, regression) { CV_HaussTest test; test.safe_run(); }
}
vector <Point2f> CV_ShapeTest::convertContourType(const Mat& currentQuery, int n)
-{
+{
vector<vector<Point> > _contoursQuery;
vector <Point2f> contoursQuery;
findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE);
imshow("QUERY", queryToShow);
moveWindow("TEST", 0,0);
vector<Point> contQuery = simpleContour(query);
- int bestMatch;
+ int bestMatch = 0;
float bestDis=FLT_MAX;
for ( int ii=1; ii<=20; ii++ )
{
BFMatcher matcher(NORM_L2);
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
-
+
// drawing the results
namedWindow("matches", 1);
Mat img_matches;