I'm currently writing a program to detect license plate text. I have a class PossiblePlate with member variables, at one point in main I would like to sort a vector of PossiblePlate objects in descending order by the number of characters detected in the plate, which is in the member variable strChars. Here is the relevant code:
in main:
std::sort(vectorOfPossiblePlates.begin(), vectorOfPossiblePlates.end(), PossiblePlate::sortDescendingByNumberOfChars);
PossiblePlate.h (so far, I'm probably going to add more):
// PossiblePlate.h
#ifndef POSSIBLEPLATE_H
#define POSSIBLEPLATE_H
#include <string>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
///////////////////////////////////////////////////////////////////////////////////////////////////
class PossiblePlate {
public:
// member variables ///////////////////////////////////////////////////////////////////////////
cv::Mat imgPlate;
cv::Mat imgGrayscale;
cv::Mat imgThresh;
std::vector<cv::RotatedRect> locationOfPlateInScene;
std::string strChars;
///////////////////////////////////////////////////////////////////////////////////////////////////
bool sortDescendingByNumberOfChars(const PossiblePlate &ppLeft, const PossiblePlate &ppRight);
};
#endif // end #ifndef POSSIBLEPLATE_H
here is PossiblePlate.cpp (so far, I may add more)
// PossiblePlate.cpp
#include "PossiblePlate.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
bool sortDescendingByNumberOfChars(const PossiblePlate &ppLeft, const PossiblePlate &ppRight) {
return(ppLeft.strChars.length() < ppRight.strChars.length());
}
When I run this with Visual Studio 2013 I get the following error:
Error 1 error C3867: 'PossiblePlate::sortDescendingByNumberOfChars': function call missing argument list; use '&PossiblePlate::sortDescendingByNumberOfChars' to create a pointer to member c:\visualstudio2013progs\cpp\licenseplaterecognition1\main.cpp 44 1 LicensePlateRecognition
Line 44 in main is the line in main above that calls std::sort.
I've done the same thing in other programs before without a problem. Everything I'm doing here is consistent with how I have done this in the past and with other Stack Overflow posts such as these:
Sorting a vector of objects in C++
Can anybody tell me what I'm doing wrong? I'm at a loss here, any help would be greatly appreciated.