我在一個類中創建了一個方法,該方法在opencv項目中返回一個向量。類CPP和報頭碼:錯誤LNK2019:試圖返回一個向量時
Detection::Detection(){}
vector<Rect> detection(string fileName)
{
Mat image, gray_image;
string path = "C:\\"+ fileName;
image = imread(fileName, 1);
//create a vector array to store the face found
vector<Rect> faces;
while(true)
{
...
}
return faces;
}
頭文件:
class Detection
{
public:
Detection();
vector<Rect> detection(string fileName);
};
在主要的功能是在另一個CPP文件I包括「Detection.h」,創建檢測的一個對象和一個矩形矢量,當我試圖給它們分配我已經得到了錯誤
error LNK2019: unresolved external symbol "public: class std::vector<class cv::Rect_<int>,class std::allocator<class cv::Rect_<int> > > __thiscall Detection::detection(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function _main
主要功能代碼:
vector<Rect> detections;
Detection object;
detections = object.detection("C:\\opencvAssets/BioID_0102.pgm");
// ALTERNATIVES
//object.detection("C:\\opencvAssets/BioID_0102.pgm").swap(detections);
//detections(object.detection("C:\\opencvAssets/BioID_0102.pgm"));
我在代碼中缺少什麼?
你可能忘了編譯/鏈接文件與執行 – berak