Commit 4395bad9 authored by Maria Dimashova's avatar Maria Dimashova

fixed linker errors on Win and some warnings

parent 121e51d3
...@@ -1505,7 +1505,7 @@ void CalonderDescriptorExtractor<T>::compute( const cv::Mat& image, ...@@ -1505,7 +1505,7 @@ void CalonderDescriptorExtractor<T>::compute( const cv::Mat& image,
int offset = patchSize / 2; int offset = patchSize / 2;
for (size_t i = 0; i < keypoints.size(); ++i) { for (size_t i = 0; i < keypoints.size(); ++i) {
cv::Point2f pt = keypoints[i].pt; cv::Point2f pt = keypoints[i].pt;
IplImage ipl = image( Rect(pt.x - offset, pt.y - offset, patchSize, patchSize) ); IplImage ipl = image( Rect((int)(pt.x - offset), (int)(pt.y - offset), patchSize, patchSize) );
classifier_.getSignature( &ipl, descriptors.ptr<T>(i)); classifier_.getSignature( &ipl, descriptors.ptr<T>(i));
} }
} }
...@@ -1515,7 +1515,7 @@ void CalonderDescriptorExtractor<T>::read( const FileNode& ) ...@@ -1515,7 +1515,7 @@ void CalonderDescriptorExtractor<T>::read( const FileNode& )
{} {}
template<typename T> template<typename T>
void CalonderDescriptorExtractor<T>::write( FileStorage&s ) const void CalonderDescriptorExtractor<T>::write( FileStorage& ) const
{} {}
CV_EXPORTS Ptr<DescriptorExtractor> createDescriptorExtractor( const string& descriptorExtractorType ); CV_EXPORTS Ptr<DescriptorExtractor> createDescriptorExtractor( const string& descriptorExtractorType );
......
...@@ -79,11 +79,11 @@ Mat windowedMatchingMask( const vector<KeyPoint>& keypoints1, const vector<KeyPo ...@@ -79,11 +79,11 @@ Mat windowedMatchingMask( const vector<KeyPoint>& keypoints1, const vector<KeyPo
static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& color, int flags ) static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& color, int flags )
{ {
Point center( p.pt.x * draw_multiplier, p.pt.y * draw_multiplier ); Point center( cvRound(p.pt.x * draw_multiplier), cvRound(p.pt.y * draw_multiplier) );
if( flags & DrawMatchesFlags::DRAW_RICH_KEYPOINTS ) if( flags & DrawMatchesFlags::DRAW_RICH_KEYPOINTS )
{ {
int radius = p.size/2 * draw_multiplier; // KeyPoint::size is a diameter int radius = cvRound(p.size/2 * draw_multiplier); // KeyPoint::size is a diameter
// draw the circles around keypoints with the keypoints size // draw the circles around keypoints with the keypoints size
circle( img, center, radius, color, 1, CV_AA, draw_shift_bits ); circle( img, center, radius, color, 1, CV_AA, draw_shift_bits );
...@@ -91,8 +91,9 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col ...@@ -91,8 +91,9 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col
// draw orientation of the keypoint, if it is applicable // draw orientation of the keypoint, if it is applicable
if( p.angle != -1 ) if( p.angle != -1 )
{ {
float srcAngleRad = p.angle*CV_PI/180; float srcAngleRad = p.angle*(float)CV_PI/180.f;
Point orient(cos(srcAngleRad)*radius, sin(srcAngleRad)*radius); Point orient(cvRound(cos(srcAngleRad)*radius),
cvRound(sin(srcAngleRad)*radius));
line( img, center, center+orient, color, 1, CV_AA, draw_shift_bits ); line( img, center, center+orient, color, 1, CV_AA, draw_shift_bits );
} }
#if 0 #if 0
...@@ -175,7 +176,9 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 , ...@@ -175,7 +176,9 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 ,
pt2 = kp2.pt, pt2 = kp2.pt,
dpt2 = Point2f( std::min(pt2.x+outImg1.cols, float(outImg.cols-1)), pt2.y ); dpt2 = Point2f( std::min(pt2.x+outImg1.cols, float(outImg.cols-1)), pt2.y );
line( outImg, Point(pt1.x*draw_multiplier, pt1.y*draw_multiplier), Point(dpt2.x*draw_multiplier, dpt2.y*draw_multiplier), line( outImg,
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 ); color, 1, CV_AA, draw_shift_bits );
} }
...@@ -461,7 +464,7 @@ void BruteForceMatcher<L2<float> >::matchImpl( const Mat& query, const Mat& mask ...@@ -461,7 +464,7 @@ void BruteForceMatcher<L2<float> >::matchImpl( const Mat& query, const Mat& mask
{ {
match.indexQuery = i; match.indexQuery = i;
double queryNorm = norm( query.row(i) ); double queryNorm = norm( query.row(i) );
match.distance = sqrt( minVal + queryNorm*queryNorm ); match.distance = (float)sqrt( minVal + queryNorm*queryNorm );
matches.push_back( match ); matches.push_back( match );
} }
} }
......
...@@ -46,18 +46,18 @@ ...@@ -46,18 +46,18 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
inline Point2f applyHomography( const Mat_<double>& H, const Point2f& pt ) static inline Point2f applyHomography( const Mat_<double>& H, const Point2f& pt )
{ {
double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2); double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2);
if( z ) if( z )
{ {
double w = 1./z; double w = 1./z;
return Point2f( (H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w, (H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w ); return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w), (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) );
} }
return Point2f( numeric_limits<double>::max(), numeric_limits<double>::max() ); return Point2f( numeric_limits<float>::max(), numeric_limits<float>::max() );
} }
inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A ) static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A )
{ {
A.create(2,2); A.create(2,2);
double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2), double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2),
...@@ -110,12 +110,12 @@ EllipticKeyPoint::EllipticKeyPoint( const Point2f& _center, const Scalar& _ellip ...@@ -110,12 +110,12 @@ EllipticKeyPoint::EllipticKeyPoint( const Point2f& _center, const Scalar& _ellip
Mat_<double> M = getSecondMomentsMatrix(_ellipse), eval; Mat_<double> M = getSecondMomentsMatrix(_ellipse), eval;
eigen( M, eval ); eigen( M, eval );
assert( eval.rows == 2 && eval.cols == 1 ); assert( eval.rows == 2 && eval.cols == 1 );
axes.width = 1.f / sqrt(eval(0,0)); axes.width = 1.f / (float)sqrt(eval(0,0));
axes.height = 1.f / sqrt(eval(1,0)); axes.height = 1.f / (float)sqrt(eval(1,0));
float ac_b2 = ellipse[0]*ellipse[2] - ellipse[1]*ellipse[1]; double ac_b2 = ellipse[0]*ellipse[2] - ellipse[1]*ellipse[1];
boundingBox.width = sqrt(ellipse[2]/ac_b2); boundingBox.width = (float)sqrt(ellipse[2]/ac_b2);
boundingBox.height = sqrt(ellipse[0]/ac_b2); boundingBox.height = (float)sqrt(ellipse[0]/ac_b2);
} }
Mat_<double> EllipticKeyPoint::getSecondMomentsMatrix( const Scalar& _ellipse ) Mat_<double> EllipticKeyPoint::getSecondMomentsMatrix( const Scalar& _ellipse )
...@@ -223,7 +223,7 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El ...@@ -223,7 +223,7 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El
fac=3; fac=3;
maxDist = maxDist*4; maxDist = maxDist*4;
fac = 1.0/(fac*fac); fac = 1.f/(fac*fac);
EllipticKeyPoint keypoint1a = EllipticKeyPoint( kp1.center, Scalar(fac*kp1.ellipse[0], fac*kp1.ellipse[1], fac*kp1.ellipse[2]) ); EllipticKeyPoint keypoint1a = EllipticKeyPoint( kp1.center, Scalar(fac*kp1.ellipse[0], fac*kp1.ellipse[1], fac*kp1.ellipse[2]) );
...@@ -246,8 +246,8 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El ...@@ -246,8 +246,8 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El
float miny = floor((-keypoint1a.boundingBox.height < (diff.y-keypoint2a.boundingBox.height)) ? float miny = floor((-keypoint1a.boundingBox.height < (diff.y-keypoint2a.boundingBox.height)) ?
-keypoint1a.boundingBox.height : (diff.y-keypoint2a.boundingBox.height)); -keypoint1a.boundingBox.height : (diff.y-keypoint2a.boundingBox.height));
float mina = (maxx-minx) < (maxy-miny) ? (maxx-minx) : (maxy-miny) ; float mina = (maxx-minx) < (maxy-miny) ? (maxx-minx) : (maxy-miny) ;
float dr = mina/50.0; float dr = mina/50.f;
float bua = 0, bna = 0; float bua = 0.f, bna = 0.f;
//compute the area //compute the area
for( float rx1 = minx; rx1 <= maxx; rx1+=dr ) for( float rx1 = minx; rx1 <= maxx; rx1+=dr )
{ {
...@@ -256,8 +256,8 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El ...@@ -256,8 +256,8 @@ static void overlap( const vector<EllipticKeyPoint>& keypoints1, const vector<El
{ {
float ry2=ry1-diff.y; float ry2=ry1-diff.y;
//compute the distance from the ellipse center //compute the distance from the ellipse center
float e1 = keypoint1a.ellipse[0]*rx1*rx1+2*keypoint1a.ellipse[1]*rx1*ry1+keypoint1a.ellipse[2]*ry1*ry1; float e1 = (float)(keypoint1a.ellipse[0]*rx1*rx1+2*keypoint1a.ellipse[1]*rx1*ry1+keypoint1a.ellipse[2]*ry1*ry1);
float e2 = keypoint2a.ellipse[0]*rx2*rx2+2*keypoint2a.ellipse[1]*rx2*ry2+keypoint2a.ellipse[2]*ry2*ry2; float e2 = (float)(keypoint2a.ellipse[0]*rx2*rx2+2*keypoint2a.ellipse[1]*rx2*ry2+keypoint2a.ellipse[2]*ry2*ry2);
//compute the area //compute the area
if( e1<1 && e2<1 ) bna++; if( e1<1 && e2<1 ) bna++;
if( e1<1 || e2<1 ) bua++; if( e1<1 || e2<1 ) bua++;
......
...@@ -118,7 +118,7 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 ) ...@@ -118,7 +118,7 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 )
Point2f p1 = kp1.pt; Point2f p1 = kp1.pt;
Point2f p2 = kp2.pt; Point2f p2 = kp2.pt;
float c = norm( p1 - p2 ); float c = (float)norm( p1 - p2 );
float ovrl = 0.f; float ovrl = 0.f;
...@@ -143,7 +143,7 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 ) ...@@ -143,7 +143,7 @@ float KeyPoint::overlap( const KeyPoint& kp1, const KeyPoint& kp2 )
float triangleAreaB = b_2 * sinAlpha * cosAlpha; float triangleAreaB = b_2 * sinAlpha * cosAlpha;
float intersectionArea = segmentAreaA + segmentAreaB - triangleAreaA - triangleAreaB; float intersectionArea = segmentAreaA + segmentAreaB - triangleAreaA - triangleAreaB;
float unionArea = (a_2 + b_2) * CV_PI - intersectionArea; float unionArea = (a_2 + b_2) * (float)CV_PI - intersectionArea;
ovrl = intersectionArea / unionArea; ovrl = intersectionArea / unionArea;
} }
......
...@@ -125,7 +125,7 @@ void CV_CalonderTest::run(int) ...@@ -125,7 +125,7 @@ void CV_CalonderTest::run(int)
CalonderDescriptorExtractor<float> fde(dir + "/classifier.rtc"); CalonderDescriptorExtractor<float> fde(dir + "/classifier.rtc");
Mat fdescriptors; Mat fdescriptors;
double t = getTickCount(); double t = (double)getTickCount();
fde.compute(img, keypoints, fdescriptors); fde.compute(img, keypoints, fdescriptors);
t = getTickCount() - t; t = getTickCount() - t;
ts->printf(CvTS::LOG, "\nAverage time of computiting float descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/fdescriptors.rows ); ts->printf(CvTS::LOG, "\nAverage time of computiting float descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/fdescriptors.rows );
...@@ -143,7 +143,7 @@ void CV_CalonderTest::run(int) ...@@ -143,7 +143,7 @@ void CV_CalonderTest::run(int)
CalonderDescriptorExtractor<uchar> cde(dir + "/classifier.rtc"); CalonderDescriptorExtractor<uchar> cde(dir + "/classifier.rtc");
Mat cdescriptors; Mat cdescriptors;
t = getTickCount(); t = (double)getTickCount();
cde.compute(img, keypoints, cdescriptors); cde.compute(img, keypoints, cdescriptors);
t = getTickCount() - t; t = getTickCount() - t;
ts->printf(CvTS::LOG, "Average time of computiting uchar descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/cdescriptors.rows ); ts->printf(CvTS::LOG, "Average time of computiting uchar descriptor = %g ms\n", t/((double)cvGetTickFrequency()*1000.)/cdescriptors.rows );
......
...@@ -52,8 +52,35 @@ using namespace cv; ...@@ -52,8 +52,35 @@ using namespace cv;
* Functions to evaluate affine covariant detectors and descriptors. * * Functions to evaluate affine covariant detectors and descriptors. *
\****************************************************************************************/ \****************************************************************************************/
Point2f applyHomography( const Mat_<double>& H, const Point2f& pt ); static inline Point2f applyHomography( const Mat_<double>& H, const Point2f& pt )
void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A ); {
double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2);
if( z )
{
double w = 1./z;
return Point2f( (H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w, (H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w );
}
return Point2f( numeric_limits<float>::max(), numeric_limits<float>::max() );
}
static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A )
{
A.create(2,2);
double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2),
p2 = H(1,0)*pt.x + H(1,1)*pt.y + H(1,2),
p3 = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2),
p3_2 = p3*p3;
if( p3 )
{
A(0,0) = H(0,0)/p3 - p1*H(2,0)/p3_2; // fxdx
A(0,1) = H(0,1)/p3 - p1*H(2,1)/p3_2; // fxdy
A(1,0) = H(1,0)/p3 - p2*H(2,0)/p3_2; // fydx
A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx
}
else
A.setTo(Scalar::all(numeric_limits<double>::max()));
}
void calcKeyPointProjections( const vector<KeyPoint>& src, const Mat_<double>& H, vector<KeyPoint>& dst ) void calcKeyPointProjections( const vector<KeyPoint>& src, const Mat_<double>& H, vector<KeyPoint>& dst )
{ {
...@@ -1066,7 +1093,7 @@ int DescriptorQualityTest::processResults( int datasetIdx, int caseIdx ) ...@@ -1066,7 +1093,7 @@ int DescriptorQualityTest::processResults( int datasetIdx, int caseIdx )
Quality valid = validQuality[datasetIdx][caseIdx], calc = calcQuality[datasetIdx][caseIdx]; Quality valid = validQuality[datasetIdx][caseIdx], calc = calcQuality[datasetIdx][caseIdx];
bool isBadAccuracy; bool isBadAccuracy;
const float rltvEps = 0.001; const float rltvEps = 0.001f;
ts->printf(CvTS::LOG, "%s: calc=%f, valid=%f", RECALL.c_str(), calc.recall, valid.recall ); ts->printf(CvTS::LOG, "%s: calc=%f, valid=%f", RECALL.c_str(), calc.recall, valid.recall );
isBadAccuracy = valid.recall - calc.recall > rltvEps; isBadAccuracy = valid.recall - calc.recall > rltvEps;
testLog( ts, isBadAccuracy ); testLog( ts, isBadAccuracy );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment