Commit 5d86aa25 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov

Fix rounding in FREAK descriptor

parent 1903d9fd
......@@ -538,7 +538,12 @@ void FREAK_Impl::computeDescriptors( InputArray _image, std::vector<KeyPoint>& k
}
keypoints[k].angle = static_cast<float>(atan2((float)direction1,(float)direction0)*(180.0/CV_PI));//estimate orientation
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)+0.5);
if(keypoints[k].angle < 0.f)
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)-0.5);
else
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)+0.5);
if( thetaIdx < 0 )
thetaIdx += FREAK_NB_ORIENTATION;
......@@ -590,7 +595,11 @@ void FREAK_Impl::computeDescriptors( InputArray _image, std::vector<KeyPoint>& k
}
keypoints[k].angle = static_cast<float>(atan2((float)direction1,(float)direction0)*(180.0/CV_PI)); //estimate orientation
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)+0.5);
if(keypoints[k].angle < 0.f)
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)-0.5);
else
thetaIdx = int(FREAK_NB_ORIENTATION*keypoints[k].angle*(1/360.0)+0.5);
if( thetaIdx < 0 )
thetaIdx += FREAK_NB_ORIENTATION;
......@@ -672,7 +681,11 @@ imgType FREAK_Impl::meanIntensity( InputArray _image, InputArray _integral,
ret_val -= integral.at<iiType>(y_bottom,x_left);
ret_val += integral.at<iiType>(y_top,x_left);
ret_val -= integral.at<iiType>(y_top,x_right);
ret_val = ret_val/( (x_right-x_left)* (y_bottom-y_top) );
const int area = (x_right - x_left) * (y_bottom - y_top);
if(ret_val > 0)
ret_val = (ret_val + area/2) / area;
else
ret_val = (ret_val - area/2) / area;
//~ std::cout<<integral.step[1]<<std::endl;
return static_cast<imgType>(ret_val);
}
......
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