我喜欢在班上使用这个DPMDetector对象。
namespace cv
{
namespace dpm
{
/** @brief This is a C++ abstract class, it provides external user API to work with DPM.
*/
class CV_EXPORTS_W DPMDetector
{
public:
struct CV_EXPORTS_W ObjectDetection
{
ObjectDetection();
ObjectDetection( const Rect& rect, float score, int classID=-1 );
Rect rect;
float score;
int classID;
};
virtual bool isEmpty() const = 0;
/** @brief Find rectangular regions in the given image that are likely to contain objects of loaded classes
(models) and corresponding confidence levels.
@param image An image.
@param objects The detections: rectangulars, scores and class IDs.
*/
virtual void detect(cv::Mat &image, CV_OUT std::vector<ObjectDetection> &objects) = 0;
/** @brief Return the class (model) names that were passed in constructor or method load or extracted from
models filenames in those methods.
*/
virtual std::vector<std::string> const& getClassNames() const = 0;
/** @brief Return a count of loaded models (classes).
*/
virtual size_t getClassCount() const = 0;
/** @brief Load the trained models from given .xml files and return cv::Ptr\<DPMDetector\>.
@param filenames A set of filenames storing the trained detectors (models). Each file contains one
model. See examples of such files here `/opencv_extra/testdata/cv/dpm/VOC2007_Cascade/`.
@param classNames A set of trained models names. If it's empty then the name of each model will be
constructed from the name of file containing the model. E.g. the model stored in
"/home/user/cat.xml" will get the name "cat".
*/
static cv::Ptr<DPMDetector> create(std::vector<std::string> const &filenames,
std::vector<std::string> const &classNames = std::vector<std::string>());
virtual ~DPMDetector(){}
};
} // namespace dpm
} // namespace cv
我试过
class myClass{
private:
DPMDetector *detector;//first approach
cv::Ptr<DPMDetector> detector;//second approach
public:
myClass();
void fun1(void);
void fun2(void);
}
fun1 and fun2 will use detector;
如果我喜欢
myClass::myClass(){
detector->create(vector<string>(1, "inriaperson.xml"));//first approach
detector = DPMDetector::create(vector<string>(1, "inriaperson.xml"));//second approach
}
对于第一种和第二种方法,我都有像
这样的错误undefined reference to `cv::dpm::DPMDetector::create(std::vector<std::string, std::allocator<std::string> > const&, std::vector<std::string, std::allocator<std::string> > const&)'
如何创建DPMDetector对象以便fun1和fun2可以使用?