I am getting the following error when building my code:
Error C2064: term does not evaluate to a function taking 1 argument
I read the other posts concerning this error and added the keyword this
inside my lambda function but I am still getting the same error.
I am trying to use a class member function inside another class member function using a C++ lambda function (std::remove_if
).
class LineSegments
{
public:
LineSegments();
float getClockwiseAngle0to180(const float& dx1, const float& dx2, const float& dy1, const float& dy2);
void eliminateParallelLineSegments(std::vector<cv::Vec4f>& lines);
~LineSegments();
};
// Constructors
LineSegments::LineSegments() {}
// Destructors
LineSegments::~LineSegments() {}
float LineSegments::getClockwiseAngle0to180(const float& dx1, const float& dx2, const float& dy1, const float& dy2) {
float dot = dx1 * dx2 + dy1 * dy2;
float det = dx1 * dy2 - dy1 * dx2;
float angle = -atan2(det, dot);
angle = angle * (180 / CV_PI);
if (angle < 0) {
angle = angle + 360;
}
if (angle >= 180) {
angle = angle - 180;
}
return angle;
}
void LineSegments::eliminateParallelLineSegments(std::vector<cv::Vec4f>& lines)
{
lines.erase(remove_if(lines.begin() + 1, lines.end(), [this](const Vec4f& left_line, const Vec4f& right_line)
{
return (abs((getClockwiseAngle0to180(0, left_line[2] - left_line[0], 1, left_line[3] - left_line[1]) - getClockwiseAngle0to180(0, right_line[2] - right_line[0], 1, right_line[3] - right_line[1]))) < 2);
})
, lines.end()
);
}
I guess it is a simple mistake but I couldn't find it for more than one hour now ;). This is just a minimal example.